lts/php-openapi-generator 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

lts/php-openapi-generator

Composer 安装命令:

composer require lts/php-openapi-generator

包简介

PHP OpenAPI 3.1+ code generator

README 文档

README

Hard fork of janephp/janephp with OpenAPI 3.1 support.

A set of libraries to generate PHP models and API clients from OpenAPI 3.1 specifications.

Why this fork?

Jane PHP does not support OpenAPI 3.1 (janephp/janephp#759). OAS 3.1 has been the current standard since February 2021, and many API providers publish 3.1 specs exclusively. The upstream maintainers have indicated they welcome PRs but have no roadmap for 3.1 support.

This fork adds:

  • Full OpenAPI 3.1 support — handles type as array (e.g. ["string", "null"]), nullable via type arrays, const, $schema, and other 3.1 features
  • PHP 8.4 — requires and targets modern PHP
  • PHPUnit 11 — test suite fully updated to PHPUnit 11 conventions
  • Strict OpenAPI spec validation via lts/strict-openapi-validator

Requirements

  • PHP 8.4+

Installation

composer require lts/php-openapi-generator

Usage

Generate a client from an OpenAPI 3.1 spec:

vendor/bin/php-openapi generate --config-file .php-openapi

Example .php-openapi config:

<?php

return [
    'openapi-file' => __DIR__ . '/openapi.yaml',
    'namespace'    => 'MyApp\Client',
    'directory'    => __DIR__ . '/generated',
];

Symfony Integration

To register the generate command in a Symfony application, add it as a console command in your services config:

// config/services.php
use LongTermSupport\OpenApiGenerator\Component\OpenApiCommon\Console\Command\GenerateCommand;
use LongTermSupport\OpenApiGenerator\Component\OpenApiCommon\Console\Loader\ConfigLoader;
use LongTermSupport\OpenApiGenerator\Component\OpenApiCommon\Console\Loader\OpenApiMatcher;
use LongTermSupport\OpenApiGenerator\Component\OpenApiCommon\Console\Loader\SchemaLoader;
use Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;

return function (ContainerConfigurator $container): void {
    $container->services()
        ->set('php_openapi.generate_command', GenerateCommand::class)
        ->args([
            new ConfigLoader(),
            new SchemaLoader(),
            new OpenApiMatcher(),
        ])
        ->tag('console.command');
};

Then run:

bin/console php-openapi:generate --config-file .php-openapi

Upstream

Maintained by

Long Term Support Ltdjoseph@ltscommerce.dev

Credits

License

MIT — see LICENSE. Original work copyright © 2016–2017 Joel Wurtz.

统计信息

  • 总下载量: 16
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 3
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-03-24

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固