421c / autodoc-php
Automatic OpenApi documentation and TypeScript generation tool for PHP projects
Requires
- php: ^8.5
- nikic/php-parser: ^5.2
- phpstan/phpdoc-parser: ^2.1
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.64
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^11.4
- rector/rector: ^2.4
- symfony/var-dumper: ^7.1
Conflicts
- phpstan/phpstan: <2.0
This package is auto-updated.
Last update: 2026-07-19 23:14:55 UTC
README
PHP autodoc generates OpenAPI 3.1.0 documentation and TypeScript types directly from your PHP code. It reads native type declarations, performs static analysis, and uses PHPDoc when available. As your code changes, the generated documentation and types stay aligned with it.
For Laravel projects there is autodoc-laravel, which plugs into routing, request validation, Eloquent models and query builders, API resources, paginated responses and the authenticated user.
This package includes a built-in interactive viewer for exploring the generated OpenAPI documentation.
Read the documentation or explore the demo.
Upgrading from v1? See the upgrade guide.
OpenAPI
Registered routes become OpenAPI operations with parameters, request bodies, responses and schemas. Serve the generated OpenAPI 3.1.0 document through the bundled viewer or export it as JSON:
vendor/bin/autodoc openapi --config=config/autodoc.php
When caching is disabled, the OpenAPI document is regenerated each time the viewer is loaded.
TypeScript
autodoc ts keeps frontend declarations synchronized with PHP classes, enums, PHPStan type aliases, PHPDoc expressions and API routes:
vendor/bin/autodoc ts --config=config/autodoc.php
See the TypeScript documentation.
Installation
Requires PHP 8.5 or newer.
For Laravel:
composer require 421c/autodoc-laravel
For other frameworks or standalone use:
composer require 421c/autodoc-php
Continue with the installation and configuration documentation.