wadakatu/laravel-spectrum
最新稳定版本:v1.0.1
Composer 安装命令:
composer require wadakatu/laravel-spectrum
包简介
Zero-annotation OpenAPI/Swagger documentation generator for Laravel - automatic API docs from your existing code
关键字:
README 文档
README
Zero-annotation OpenAPI documentation generator for Laravel
Generate complete API docs from your existing code in seconds. No annotations required.
Documentation • Quick Start • Compare
The Problem
// ❌ Traditional approach: Annotations everywhere /** * @OA\Post( * path="/api/users", * @OA\RequestBody( * @OA\JsonContent( * @OA\Property(property="name", type="string"), * @OA\Property(property="email", type="string", format="email"), * // ... 50 more lines of annotations * ) * ), * @OA\Response(response="200", description="Success") * ) */ public function store(StoreUserRequest $request) { ... }
With Laravel Spectrum: Zero annotations needed. Your existing FormRequest and Resource classes are your documentation.
Quick Start (30 seconds)
# Install composer require wadakatu/laravel-spectrum --dev # Generate OpenAPI documentation php artisan spectrum:generate # View in browser (HTML with Swagger UI) php artisan spectrum:generate --format=html # Open: storage/app/spectrum/openapi.html
That's it. Full OpenAPI 3.1 documentation generated from your existing code.
What Gets Analyzed Automatically
| Your Code | Generated Documentation |
|---|---|
FormRequest::rules() |
Request body schemas with validation |
$request->validate([...]) |
Inline validation rules |
API Resources |
Response schemas |
Auth middleware (auth:sanctum) |
Security schemes |
Route parameters ({user}) |
Path parameters with types |
@deprecated PHPDoc |
Deprecated operation flags |
Key Features
Real-time Documentation
php artisan spectrum:watch
# Browser auto-refreshes when you change code
Built-in Mock Server
php artisan spectrum:mock
# Frontend team can develop without waiting for backend
Export to API Clients
php artisan spectrum:export postman # Postman collection php artisan spectrum:export insomnia # Insomnia workspace
High Performance
- Parallel processing for large codebases
- Incremental generation (only changed files)
- Smart caching
Why Laravel Spectrum?
| Laravel Spectrum | Swagger-PHP | Scribe | |
|---|---|---|---|
| Zero annotations | ✅ | ❌ | Partial |
| Setup time | 30 sec | Hours | ~30 min |
| FormRequest detection | ✅ | ❌ | ✅ |
| Mock server | ✅ | ❌ | ❌ |
| Live reload | ✅ | ❌ | ❌ |
| Postman/Insomnia export | ✅ | ❌ | ✅ |
| OpenAPI 3.1 | ✅ | ✅ | ❌ |
Requirements
- PHP 8.2+
- Laravel 11.x or 12.x
Documentation
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for details.
License
Laravel Spectrum is open-source software licensed under the MIT license.
Made with ❤️ by wadakatu
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-07-08