zircote/swagger-php
swagger-php generates OpenAPI 3.0/3.1/3.2 documentation from your PHP 8.2+ code using attributes (preferred) or optional Doctrine annotations. Use it via CLI or programmatically, with helpful error reporting and a full documentation site.
Start by installing via Composer (composer require zircote/swagger-php). Then, annotate your controller or DTO classes using @OA\ annotations (e.g., @OA\Get, @OA\Response, @OA\Property). Generate OpenAPI JSON/YAML by running openapi -o public/docs/openapi.json src/ (CLI tool included) or integrate OpenApi\Generator::generate() in your app. First use case: documenting a simple REST endpoint with request/response examples and validation rules using annotations.
@OA\Get(path="/users") + @OA\Parameter, @OA\Response to describe HTTP behavior.@OA\Schema, @OA\Property, and @OA\Items to define typed request/response bodies.openapi as part of CI to validate schema consistency.@OA\Info, and scan controllers automatically using Generator::scan().int, string) are not auto-inferred; use @OA\Property(type="integer") explicitly.@OA\Property(ref="...") carefully or annotate with @OA\Discriminator.@OA\ annotations before PHPDoc comments (e.g., /** @var string */) to avoid conflicts.OpenApi\Analysis to add custom processing (e.g., custom annotations, validation rules).--verbose with CLI or dump OpenApi\Analysis::$lastError to inspect parsing issues; paths must be absolute and scanned directories must exist.swagger-php version matches PHP version (e.g., v4+ requires PHP 8.0+).How can I help you explore Laravel packages today?