PHPackages                             arnedesmedt/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. arnedesmedt/openapi-codegen

ActiveLibrary[API Development](/categories/api)

arnedesmedt/openapi-codegen
===========================

A base library used to create Elastic PHP clients.

1.1.47(3y ago)015.5k↑20%7[1 PRs](https://github.com/arnedesmedt/openapi-codegen-php/pulls)Apache-2.0PHPPHP ^8

Since Jun 5Pushed 3y agoCompare

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

READMEChangelogDependencies (13)Versions (130)Used By (0)

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->connection());
    }

    /**
     * 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

39

—

LowBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity28

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity77

Established project with proven stability

 Bus Factor1

Top contributor holds 89.1% 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 ~10 days

Recently: every ~30 days

Total

128

Last Release

1216d ago

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

v1.0.5PHP ^7.4

1.0.76PHP ^7.4 || ^8.0

1.1PHP ^8

1.1.10PHP ^7.4 || ^8

### Community

Maintainers

![](https://www.gravatar.com/avatar/d995ac5d75c631ec4ac2e3092c13a0a6127be00d25be946580db0e5ad6dbe482?d=identicon)[arnedesmedt](/maintainers/arnedesmedt)

---

Top Contributors

[![arnedesmedt](https://avatars.githubusercontent.com/u/5807162?v=4)](https://github.com/arnedesmedt "arnedesmedt (196 commits)")[![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)")[![SiebeVE](https://avatars.githubusercontent.com/u/14889418?v=4)](https://github.com/SiebeVE "SiebeVE (5 commits)")[![coudenysj](https://avatars.githubusercontent.com/u/96260?v=4)](https://github.com/coudenysj "coudenysj (3 commits)")[![xvilo](https://avatars.githubusercontent.com/u/390769?v=4)](https://github.com/xvilo "xvilo (2 commits)")[![MetalArend](https://avatars.githubusercontent.com/u/1175661?v=4)](https://github.com/MetalArend "MetalArend (1 commits)")

---

Tags

clientsearchopenapielastic

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Rector

Code StylePHP\_CodeSniffer

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[elasticsearch/elasticsearch

PHP Client for Elasticsearch

5.3k178.3M943](/packages/elasticsearch-elasticsearch)[algolia/algoliasearch-client-php

API powering the features of Algolia.

69433.0M114](/packages/algolia-algoliasearch-client-php)[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k7.6M74](/packages/openai-php-laravel)

PHPackages © 2026

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