承接 elastic/openapi-codegen 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

elastic/openapi-codegen

最新稳定版本:1.0.6

Composer 安装命令:

composer require elastic/openapi-codegen

包简介

A base library used to create Elastic PHP clients.

README 文档

README

CircleCI build

Make easier clients creation by generating most of the code from an Open API specification.

Projects using the Elastic OpenAPI PHP client generator:

Contents

Getting started with the generator ????

Requirements

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

  • Docker (used to run the code generator)
  • composer

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

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

{ "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

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 for how to customize the documentation)

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

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

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.

FAQ ????

Where do I report issues with the client?

If something is not working as expected, please open an issue.

Contribute ????

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

License ????

Apache 2.0 © Elastic

Thank you to all the contributors!

elastic/openapi-codegen 适用场景与选型建议

elastic/openapi-codegen 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 274.91k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2026 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「client」 「search」 「elastic」 「openapi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 elastic/openapi-codegen 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 elastic/openapi-codegen 我们能提供哪些服务?
定制开发 / 二次开发

基于 elastic/openapi-codegen 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 274.91k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 6
  • 点击次数: 30
  • 依赖项目数: 4
  • 推荐数: 0

GitHub 信息

  • Stars: 6
  • Watchers: 22
  • Forks: 22
  • 开发语言: PHP

其他信息

  • 授权协议: Apache-2.0
  • 更新时间: 2026-01-04