Introduction

The Ultimate PHP Documentation Generator

PHP autodoc automatically generates up-to-date OpenAPI 3.1.0 documentation and TypeScript types directly from your PHP code – no PHPDoc annotations required.

Instead of relying on manually written comments, PHP autodoc reads your actual PHP code and native types to extract accurate type information. 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.

TypeScript export

Keep your frontend and backend in sync – define your types once in PHP and let PHP autodoc generate the matching TypeScript types automatically.

PHP autodoc supports exporting enums, classes, and API request/response structures 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.

How it works

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 also 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.

Tips to improve the generated documentation
  1. Enable debug mode in autodoc configuration to show any errors that may occur during code analysis. By default, debug mode is disabled and errors are silently ignored.
  2. Increase max_depth setting in autodoc configuration to allow for deeper analysis of your codebase.
  3. 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.
  4. Create custom extensions to handle domain-specific structures that PHP autodoc may not recognize by default.