Compatible with the OpenAPI Specification version 3. formerly known as Swagger.
Write the documentation inside the php source files which helps to keep the documentation in sync.
Useful error messages
Enhanced errors messages with hints and context.
Install with composer:
composer require zircote/swagger-php
Create a php file:
<?php require("vendor/autoload.php"); $openapi = \OpenApi\Generator::scan(['/path/to/project']); header('Content-Type: application/x-yaml'); echo $openapi->toYaml();
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") * ) */
And view and interact with your API using Swagger UI (opens new window)
- Getting started guide
- OpenApi Documentation (opens new window)
- OpenApi Specification (opens new window)
- Migration from 2.x to 3.x
- Learn by example (opens new window) lots of example of how to generate
- Related projects
- Swagger-php 2.x documentation (opens new window) The docs for swagger-php v2
- Swagger-php 1.x documentation The docs for swagger-php v1