Introduction
PHP API Documentation and TypeScript Type Generator
PHP autodoc automatically generates up-to-date OpenAPI 3.1.0 documentation and TypeScript types directly from your PHP code. PHPDoc annotations are supported if present, but completely optional.
For Laravel projects, autodoc-laravel offers seamless integration with routes, request validation, database models, API resources, and more.
Define your types once in PHP and let PHP autodoc generate the matching TypeScript types automatically to keep your frontend and backend types in sync.
PHP autodoc supports exporting API request/response structures, classes, enums, PHPStan type aliases and custom PHPDoc type expressions as TypeScript types. PHP autodoc-laravel extends this functionality by offering support for Laravel models and other Laravel-specific structures that need custom handling.
See TypeScript section for more info.
PHP autodoc uses PHP parser and PHPDoc parser to analyze your code and convert it into AutoDoc\DataTypes\Type objects. These objects can be used in your custom PHP autodoc extensions and are utilized in generating OpenAPI 3.1.0 schemas and TypeScript types. If you are using a static analysis tool like PHPStan, you will find that autodoc works well without any changes to your codebase.
- Enable
debugmode in autodoc configuration to show any errors that may occur during code analysis. By default,debugmode is disabled and errors are silently ignored. - Increase
max_depthsetting in autodoc configuration to allow for deeper analysis of your codebase. - Use a tool like PHPStan to analyze your codebase and fix any issues that may occur. This will improve the quality of your code and help autodoc generate more accurate documentation.
- Create custom extensions to handle domain-specific structures that PHP autodoc may not recognize by default.