kmapidocvendor / laravel-api-docs
A Laravel package for generating API documentation
Requires
- php: ^8.0
- illuminate/support: ^8.0|^9.0|^10.0|^11.0|^12.0
This package is auto-updated.
Last update: 2025-06-06 06:54:23 UTC
README
A simple and developer-friendly Laravel package for auto-generating API documentation directly from your Laravel routes, views, and controller metadata.
๐ Features
- Automatically scans your routes and generates documentation
- Artisan command to generate docs
- Blade view integration for web-based display
- Easy customization by publishing views
๐ฆ Installation
Step 1: Add Local Repository
If you're developing this package locally from a packages/
directory, add the following to your root project's composer.json
:
"repositories": [ { "type": "path", "url": "packages/KmApiDocVendor/LaravelApiDocs" } ]
Step 2: Require the Package
Run the following command from your Laravel project root:
composer require kmapidocvendor/laravel-api-docs:@dev composer dump-autoload
Step 3: Register the Service Provider (if not using auto-discovery)
If your Laravel version is below 5.5 or you're not using auto-discovery, add the provider manually to config/app.php
:
'providers' => [ // ... KmApiDocVendor\LaravelApiDocs\ApiDocsServiceProvider::class, ],
Step 4: Publish the Views (optional)
To customize the documentation UI:
php artisan vendor:publish --provider="KmApiDocVendor\LaravelApiDocs\ApiDocsServiceProvider"
This will publish the view files to:
resources/views/vendor/kmapidocs/
โ๏ธ Usage
1. Generate the Documentation
Use the artisan command to generate API documentation:
php artisan kmapidoc:generate
This will scan your routes/controllers and create structured docs.
2. View Documentation in the Browser
Once generated, you can view the documentation at:
http://your-app.test/api-docs
The view is rendered via:
$this->loadViewsFrom(__DIR__.'/resources/views', 'kmapidocs');
๐ Customizing the View
If you published the views, you can customize the layout or design:
resources/views/vendor/kmapidocs/api-docs.blade.php
๐ Project Structure
packages/
โโโ KmApiDocVendor/
โโโ LaravelApiDocs/
โโโ src/
โ โโโ ApiDocsServiceProvider.php
โ โโโ Console/
โ โโโ GenerateDocsCommand.php
โโโ resources/
โ โโโ views/
โ โโโ api-docs.blade.php
โโโ routes/
โโโ web.php
๐งช Compatibility
- Laravel Versions Supported: ^8.0, ^9.0, ^10.0, ^11.0, ^12.0
- PHP Version Required: ^8.0
๐ค Contributing
Feel free to fork, improve, and send a pull request.
All contributions are welcome and appreciated!
๐ License
MIT License ยฉ Keshab Chandra Mandal