doanphu/swagger-php-trigger-error
Composer 安装命令:
composer require doanphu/swagger-php-trigger-error
包简介
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
关键字:
README 文档
README
swagger-php
Generate interactive OpenAPI documentation for your RESTful API using doctrine annotations.
For a full list of supported annotations, please have look at the OpenApi\Annotations namespace or the documentation website.
Features
- Compatible with the OpenAPI 3.0 and 3.1 specification.
- Extracts information from code & existing phpdoc annotations.
- Command-line interface available.
- Documentation site with a getting started guide.
- Exceptional error reporting (with hints, context)
- As of PHP 8.1 all annotations are also available as PHP attributes
OpenAPI version support
swagger-php allows to generate specs either for OpenAPI 3.0.0 or OpenAPI 3.1.0.
By default the spec will be in version 3.0.0. The command line option --version may be used to change this
to 3.1.0.
Programmatically, the method Generator::setVersion() can be used to change the version.
Requirements
swagger-php requires at least PHP 7.2 for annotations and PHP 8.1 for using attributes.
Installation (with Composer)
composer require doanphu/swagger-php-trigger-error
For cli usage from anywhere install swagger-php globally and make sure to place the ~/.composer/vendor/bin directory in your PATH so the openapi executable can be located by your system.
composer global require zircote/swagger-php
Usage
Add annotations to your php files.
/** * @OA\Info(title="My First API", version="0.1") */ /** * @OA\Get( * path="/api/resource.json", * @OA\Response(response="200", description="An example resource") * ) */
Visit the Documentation website for the Getting started guide or look at the Examples directory for more examples.
Usage from php
Generate always-up-to-date documentation.
<?php require("vendor/autoload.php"); $openapi = \OpenApi\Generator::scan(['/path/to/project']); header('Content-Type: application/x-yaml'); echo $openapi->toYaml();
Documentation of how to use the Generator class can be found in the Generator reference.
Usage from the Command Line Interface
The openapi command line interface can be used to generate the documentation to a static yaml/json file.
./vendor/bin/openapi --help
Starting with version 4 the default analyser used on the command line is the new ReflectionAnalyser.
Using the --legacy flag (-l) the legacy TokenAnalyser can still be used.
Usage from the Deserializer
Generate the OpenApi annotation object from a json string, which makes it easier to manipulate objects programmatically.
<?php use OpenApi\Serializer; $serializer = new Serializer(); $openapi = $serializer->deserialize($jsonString, 'OpenApi\Annotations\OpenApi'); echo $openapi->toJson();
Usage from docker
Generate the swagger documentation to a static json file.
docker run -v "$PWD":/app -it tico/swagger-php --help
More on OpenApi & Swagger
- https://swagger.io
- https://www.openapis.org
- OpenApi Documentation
- OpenApi Specification
- Related projects
Contributing
Feel free to submit Github Issues or pull requests.
The documentation website is build from the docs folder with vitepress.
Make sure pull requests pass PHPUnit and PHP-CS-Fixer (PSR-2) tests.
To run both unit tests and linting execute:
composer test
To run static-analysis execute:
composer analyse
Running unit tests only:
./bin/phpunit
Regenerate annotation/attribute reference markup docs
composer docs:refgen
Running linting only:
composer lint
To make php-cs-fixer fix linting errors:
composer cs
doanphu/swagger-php-trigger-error 适用场景与选型建议
doanphu/swagger-php-trigger-error 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 35 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 10 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「json」 「rest」 「api」 「service discovery」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 doanphu/swagger-php-trigger-error 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 doanphu/swagger-php-trigger-error 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 doanphu/swagger-php-trigger-error 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Kinikit - PHP Application development framework MVC component
ext-json wrapper with sane defaults
A package to cast json fields, each sub-keys is castable
A PSR-7 compatible library for making CRUD API endpoints
Api bundle
swagger-php - Generate interactive documentation for your RESTful API using phpdoc annotations
统计信息
- 总下载量: 35
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2022-10-19