layout
home
hero
name
tagline
actions
Swagger-PHP
Generate OpenAPI documentation for your RESTful API.
theme
text
link
brand
User Guide →
/guide/
features
title
details
OpenAPI conformant
Generate OpenAPI documents in version 3.0 or 3.1.
title
details
Document your API inside PHP source code
Using swagger-php lets you write the API documentation inside the PHP source files which helps keeping the documentation up-to-date.
title
details
Annotation and Attribute support
Annotations can be either docblocks or PHP 8.1 attributes.
1. Install with composer:
> composer require zircote/swagger-php
Add swagger-php attributes (or legacy annotations) to your source code.
⚠️ The doctrine/annotations library used to parse annotation is going to be deprecated, so wherever
possible attributes should be used.
<<< @/snippets/minimal_api_at.php
<<< @/snippets/minimal_api_an.php
3. Generate OpenAPI documentation
> ./vendor/bin/openapi src -o openapi.yaml
4. Explore and interact with your API
Use an OpenAPI tool like Swagger UI or Scalar to explore and interact with your API.