php-nl / laravel-api-doc
Highly configurable Laravel API documentation generator
Requires
- php: ^8.3.0
- illuminate/contracts: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- livewire/livewire: ^3.0|^4.0
- phpstan/phpdoc-parser: ^2.0
Requires (Dev)
- larastan/larastan: ^3.9
- laravel/pint: ^1.29
- orchestra/testbench: ^11.0
- phpunit/phpunit: ^12.5
This package is auto-updated.
Last update: 2026-03-24 21:00:21 UTC
README
Laravel API Doc
A highly configurable, beautiful, and interactive API documentation generator for Laravel.
Laravel API Doc is an elegant, zero-configuration API documentation package designed to give your Laravel projects a beautiful, Stoplight Elements-inspired interactive dashboard out of the box.
It automatically parses your routes, form requests, and parameters to generate a live, testable documentation portal where you and your team can try out endpoints seamlessly.
โจ Features
- Beautiful UI: A premium, fully responsive 3-column layout built with Livewire and Tailwind CSS.
- Interactive "Try It Out" Panel: Test any endpoint directly from your browser.
- Global Authentication: Configure Bearer Tokens, Basic Auth, or API Keys directly from the dashboard to authenticate your test requests.
- Auto-Discovery: Automatically detects endpoints, methods, and route groups.
- Zero Config Required: Just install and visit
/docs/api!
๐ฆ Installation
You can install the package via composer:
composer require php-nl/laravel-api-doc
Next, you can publish the configuration file and assets using:
php artisan vendor:publish --provider="PhpNl\LaravelApiDoc\LaravelApiDocServiceProvider"
๐ Usage
Once installed, simply navigate to the predefined documentation route in your browser:
http://your-app.test/docs/api
You will be greeted by the API Documentation Dashboard. From here you can:
- Browse through your API routes logically grouped by domain.
- View the description, parameters, and required payloads for each route.
- Use the Security & Authentication configuration to authenticate globally.
- Execute real-time requests against your application.
Defining Endpoints
The package leverages Laravel's native routing metadata and reflection to parse documentation. Standard PHPDoc blocks, FormRequest validations, and route groupings are automatically extracted to document your API.
Global Authentication
When interacting with private APIs, you don't need to manually enter tokens for every request. On the Welcome Screen of the documentation dashboard, use the Security & Authentication panel to define yours:
- Bearer Token
- Basic Auth
- API Key (Header or Query Parameter)
Once set, this authentication state is persisted for your session and can be toggled per-endpoint when running test queries.
โ๏ธ Configuration
You can fully customize the look and feel, available themes, and base extraction rules by modifying the published configuration file at config/laravel-api-doc.php.
return [ 'ui' => [ 'title' => 'My API Documentation', 'theme' => [ 'primary_color' => '#3b82f6', // Customize your brand color! 'background_color' => '#f8fafc', ], ], // ... ];
๐งช Testing
composer test
๐ Contributing
Please see CONTRIBUTING for details.
๐ Security Vulnerabilities
If you discover any security-related issues, please email directly instead of using the issue tracker.
๐ License
The MIT License (MIT). Please see License File for more information.