PHPackages                             elastic/openapi-codegen - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. elastic/openapi-codegen

AbandonedArchivedLibrary[API Development](/categories/api)

elastic/openapi-codegen
=======================

A base library used to create Elastic PHP clients.

1.0.6(2y ago)6291.1k↓55.8%22[1 issues](https://github.com/elastic/openapi-codegen-php/issues)[3 PRs](https://github.com/elastic/openapi-codegen-php/pulls)4Apache-2.0PHPPHP ^5.6|^7.0|^8.0CI failing

Since Jun 5Pushed 1y ago20 watchersCompare

[ Source](https://github.com/elastic/openapi-codegen-php)[ Packagist](https://packagist.org/packages/elastic/openapi-codegen)[ Docs](https://github.com/elastic/openapi-codegen-php)[ RSS](/packages/elastic-openapi-codegen/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (6)Dependencies (7)Versions (10)Used By (4)

Elastic OpenAPI PHP client generator.
=====================================

[](#elastic-openapi-php-client-generator)

[![CircleCI build](https://camo.githubusercontent.com/2986606604acdc70550f3517fba39169febca3213d7d9faa66684f5d41f8a346/68747470733a2f2f636972636c6563692e636f6d2f67682f656c61737469632f6f70656e6170692d636f646567656e2d7068702e7376673f7374796c653d737667)](https://circleci.com/gh/elastic/openapi-codegen-php)

> Make easier clients creation by generating most of the code from an Open API specification.
>
> Projects using the Elastic OpenAPI PHP client generator:
>
> - [Elastic Site Search Official PHP client](https://github.com/elastic/site-search-php/)
> - [Elastic App Search Official PHP client](https://github.com/elastic/app-search-php/)

Contents
--------

[](#contents)

- [Getting started](#getting-started-with-the-generator-)
- [Using the client](#Using-the-client)
- [FAQ](#faq-)
- [Contribute](#contribute-)
- [License](#license-)

---

Getting started with the generator 🐣
------------------------------------

[](#getting-started-with-the-generator-)

### Requirements

[](#requirements)

We assume you have the following components installed and available in your environment :

> - Docker (used to run the code generator)
> - composer

### Initiliaze project

[](#initiliaze-project)

When you want to create a new client you have first to create a new composer project :

```
composer create-project my-new-fancy-client
```

Once the project is created you should pimp up your `composer.json` file (package name, author, ...). Make sure the autoload section contains the PHP namespace you want to use for your client (here `Fancy\Client`):

```
"autoload": {
  "psr-4": {
    "Fancy\\Client\\": ""
  }
}
```

Once the project is created , you have to append the code generator as a requirement of the project:

```
composer require elastic/openapi-codegen
```

### Configuring the generator

[](#configuring-the-generator)

By convention, the code generator expect the `resources/api` folder containing two files :

- **`api-spec.yml`** : The OpenAPI specification that describe the server API. You can find a full featured example at :
- **`config.json`** : A configuration file contains important variable variables that allow to configure both code and documentation generation :

```
{
    "gitUserId": "myorg",
    "gitRepoId": "my-new-fancy-client",
    "artifactVersion": "1.0.0",
    "invokerPackage": "Fancy\\Client",
    "helpUrl": "https://discuss.elastic.co/c/site-search",
    "copyright": "© [Elastic](https://github.com/elastic)"
}
```

### Running the generator

[](#running-the-generator)

Once the project is setup and the generator is configured, you can run code generation by using the launcher script from the root of your project :

```
vendor/bin/elastic-openapi-codegen.sh

```

The generator will create or update the following files in your project :

- **`Client.php`**: The client class that contains one method for each paths / operation of your specification.
- **`Endpoint/*.php`**: One endpoint class for each path / operation of your specification.
- **`README.md`**: The Readme of your project (see [here](#Customize-Documentation) for how to customize the documentation)

### Create the client builder

[](#create-the-client-builder)

Client instantiation logic is very specific for each project and need to be customized for each project (authentication management, error handling). At the same time end users of your client expect a very easy to use method to instantiate the client.

Here is a code for providing a very basic client builder to end users:

```
namespace Fancy\Client;

class ClientBuilder extends \Elastic\OpenApi\Codegen\AbstractClientBuilder
{
    /**
     * Return the configured client.
     *
     * @return \Fancy\Client\Client
     */
    public function build()
    {
        return new Client($this->getEndpointBuilder(), $this->getConnection());
    }

    /**
     * Endpoint builder is in charge of resolving the endpoint classes.
     * Need to be configured with your own namespace.
     */
    protected function getEndpointBuilder()
    {
        return new \Elastic\OpenApi\Codegen\Endpoint\Builder(__NAMESPACE__ . '\Endpoint');
    }
}
```

Using the client
----------------

[](#using-the-client)

Once you will have fulfilled the tasks above, it is very simple for end user to get client they can use :

```
$clientBuilder = new \Fancy\Client\ClientBuilder();
$client = $clientBuilder->build();
```

### Customization

[](#customization)

Now you have a working client, there is several things that you may want to customize :

- Client and Endpoint code generation
- Documentation generation
- Connection logic : request and response handling, authentication, ...

You can find a full documentation of available extension point in the [Customization documentation](docs/Customization.md).

FAQ 🔮
-----

[](#faq-)

### Where do I report issues with the client?

[](#where-do-i-report-issues-with-the-client)

If something is not working as expected, please open an [issue](https://github.com/elastic/openapi-codegen-php/issues/new).

Contribute 🚀
------------

[](#contribute-)

We welcome contributors to the project. Before you begin, a couple notes...

- Before opening a pull request, please create an issue to [discuss the scope of your proposal](https://github.com/elastic/openapi-codegen-php/issues).
- Please write simple code and concise documentation, when appropriate.

License 📗
---------

[](#license-)

[Apache 2.0](https://github.com/elastic/openapi-codegen-php/blob/master/LICENSE) © [Elastic](https://github.com/elastic)

Thank you to all the [contributors](https://github.com/elastic/openapi-codegen-php/graphs/contributors)!

###  Health Score

44

—

FairBetter than 90% of packages

Maintenance23

Infrequent updates — may be unmaintained

Popularity43

Moderate usage in the ecosystem

Community29

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 53.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~270 days

Recently: every ~382 days

Total

7

Last Release

962d ago

PHP version history (2 changes)1.0.0PHP ^5.6|^7.0

1.0.5PHP ^5.6|^7.0|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/75c7c511421feb14316a01d29a7566bd4fdd97147b5a4f3faa5a065f9d0a0193?d=identicon)[ezimuel](/maintainers/ezimuel)

![](https://avatars.githubusercontent.com/u/529238?v=4)[Aurélien FOUCRET](/maintainers/afoucret)[@afoucret](https://github.com/afoucret)

![](https://avatars.githubusercontent.com/u/1427475?v=4)[Jason Stoltzfus](/maintainers/JasonStoltz)[@JasonStoltz](https://github.com/JasonStoltz)

---

Top Contributors

[![afoucret](https://avatars.githubusercontent.com/u/529238?v=4)](https://github.com/afoucret "afoucret (8 commits)")[![JasonStoltz](https://avatars.githubusercontent.com/u/1427475?v=4)](https://github.com/JasonStoltz "JasonStoltz (5 commits)")[![amineSt](https://avatars.githubusercontent.com/u/90190753?v=4)](https://github.com/amineSt "amineSt (1 commits)")[![tutelaris](https://avatars.githubusercontent.com/u/5709507?v=4)](https://github.com/tutelaris "tutelaris (1 commits)")

---

Tags

elasticelastic-app-searchelastic-site-searchphpswiftypeclientsearchopenapielastic

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/elastic-openapi-codegen/health.svg)

```
[![Health](https://phpackages.com/badges/elastic-openapi-codegen/health.svg)](https://phpackages.com/packages/elastic-openapi-codegen)
```

###  Alternatives

[algolia/algoliasearch-client-php

API powering the features of Algolia.

69735.1M159](/packages/algolia-algoliasearch-client-php)[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k187.3M1.1k](/packages/elasticsearch-elasticsearch)[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[api-platform/metadata

API Resource-oriented metadata attributes and factories

275.0M219](/packages/api-platform-metadata)[avalara/avataxclient

Client library for Avalara's AvaTax suite of business tax calculation and processing services. Uses the REST v2 API.

528.5M7](/packages/avalara-avataxclient)[keboola/storage-api-client

Keboola Storage API PHP Client

10405.9k40](/packages/keboola-storage-api-client)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
