silverstripe-terraformers/openapi-codegen-php-8
最新稳定版本:1.0.5
Composer 安装命令:
composer require silverstripe-terraformers/openapi-codegen-php-8
包简介
A base library used to create Elastic PHP clients.
README 文档
README
⚠️ This client is abandoned ⚠️
This package is here purely to serve the Elastic OpenAPI PHP client generator with PHP 8 as an allowed platform requirement
All credit and praise goes to the contributors of Elastic OpenAPI PHP client generator
Elastic OpenAPI PHP client generator.
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 :
-
api-spec.yml: The OpenAPI specification that describe the server API. You can find a full featured example at : https://github.com/swiftype/swiftype-site-search-php/blob/master/resources/api/api-spec.yml -
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
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...
- Before opening a pull request, please create an issue to discuss the scope of your proposal.
- Please write simple code and concise documentation, when appropriate.
License 📗
Thank you to all the contributors!
silverstripe-terraformers/openapi-codegen-php-8 适用场景与选型建议
silverstripe-terraformers/openapi-codegen-php-8 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.87k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 06 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「client」 「search」 「elastic」 「openapi」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 silverstripe-terraformers/openapi-codegen-php-8 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 silverstripe-terraformers/openapi-codegen-php-8 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 silverstripe-terraformers/openapi-codegen-php-8 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A Laravel package to retrieve data from Google Search Console
This package includes a script and fail2ban configuration that allows you to use fail2ban when utilizing AWS elastic load balancer (ELB) and an apache webserver.
Indexed Search Autocomplete - Extends the TYPO3 Core Extension Indexed_Search searchform with an autocomplete feature.
Elastic Driver for Laravel Scout
Abstraction Layer to index and search entities
Package for send emails with attachments via elastic email driver
统计信息
- 总下载量: 4.87k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-06-12