A PHP library for generating OpenAPI documentation from PHP attributes or annotations.
swagger-php is a PHP library that generates interactive OpenAPI documentation for RESTful APIs. It extracts metadata directly from PHP code using modern PHP attributes or, for backward compatibility, Doctrine annotations, and supports OpenAPI specifications 3.0, 3.1, and 3.2.
PHP developers building RESTful APIs who need to generate and maintain accurate, up-to-date OpenAPI documentation directly from their codebase.
Developers choose swagger-php for its modern, attribute-based approach that integrates seamlessly with PHP 8.2+, offering automatic type resolution for complex generic type-hints and providing both programmatic and CLI usage options for flexible integration into development workflows.
A php swagger annotation and parsing library
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Supports OpenAPI 3.0, 3.1, and 3.2 specifications, allowing developers to adopt the latest standards and switch versions via CLI or programmatically.
Utilizes PHP 8.2+ attributes for clean, type-safe configuration, reducing boilerplate and aligning with contemporary PHP development practices as highlighted in the README.
Leverages symfony/type-info to automatically resolve complex generic type-hints from PHPDoc blocks, simplifying schema definitions without manual attribute configuration.
Offers both programmatic access via the Generator class and a command-line interface, enabling integration into various workflows like CI/CD pipelines or runtime documentation generation.
Requires PHP 8.2 or higher, which excludes projects on older PHP versions and may force costly upgrades or limit adoption in legacy environments.
Doctrine annotations are deprecated and may be removed in future releases, creating a migration burden for existing codebases and adding complexity if the doctrine/annotations library is still needed.
Only generates OpenAPI specification files; developers must separately integrate tools like Swagger UI for interactive documentation, adding an extra step to the workflow.
If using annotations, the doctrine/annotations library must be manually installed as an extra dependency, increasing setup overhead and potential version conflicts.