kmapidocvendor/laravel-api-docs
Composer 安装命令:
composer require kmapidocvendor/laravel-api-docs
包简介
A Laravel package for generating API documentation
README 文档
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
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2025-06-06