nelmio/api-doc-bundle
Symfony bundle to generate OpenAPI documentation for your APIs. Provides an interactive docs UI and schema generation driven by PHP 8 attributes. Requires PHP 8.1+ and Symfony 6.4+. Includes migration guides and solid CI support.
Pros:
laravel-symfony-bundle).property_info or type_info components.Cons:
property_info, type_info), requiring workarounds (e.g., custom attribute readers, mock services).nelmio_api_doc.yaml) contrasts with Laravel’s modular config/ approach.Laravel Compatibility:
laravel-symfony-bundle to inject Symfony components (e.g., PropertyAccess, TypeInfo). Example:
// config/app.php
'providers' => [
LaravelSymfonyBridge\ServiceProvider::class,
];
phpdocumentor/reflection-docblock or rubix/attribute.Route component. Laravel’s routes can be mapped via Route::get() annotations or converted to Symfony-style routes.Validator component can be integrated via the bridge for request payload validation.Key Challenges:
property_info/type_info must be mocked or replaced with Laravel alternatives (e.g., spatie/laravel-data for DTOs).KernelEvents::CONTROLLER). Laravel’s events would need proxying.High:
symfony/property-info vs. Laravel’s illuminate/support).#[ApiProperty] → OpenAPI schema).Route annotations. Laravel’s routes must be manually synchronized or converted.Validator integrates tightly with Nelmio; Laravel’s Validator would need adaptation.Mitigation Strategies:
/api/docs) and expand.Business Justification:
darkaonline/l5-swagger, zircote/swagger-php) that better fit Laravel’s ecosystem?Technical Trade-offs:
Long-Term Maintenance:
Alternatives:
darkaj19/swagger (Laravel 5/6/7) or spatie/laravel-openapi (Laravel 8+).zircote/swagger-php + Laravel’s Route collector to generate OpenAPI manually.Core Compatibility:
symfony/property-info (for type inference) → Replace with spatie/laravel-data or phpdocumentor/reflection.symfony/http-foundation (for request/response handling) → Mock or use Laravel’s Illuminate\Http.symfony/routing (for route annotations) → Convert Laravel routes to Nelmio-compatible format.rubix/attribute or phpdocumentor/reflection-docblock.Laravel-Specific Workarounds:
| Nelmio Feature | Laravel Equivalent/Workaround |
|---|---|
#[ApiProperty] |
Use #[OpenApi\Property] (custom attribute) or annotations. |
| Symfony Events | Proxy to Laravel events (e.g., Events::dispatch()). |
property_info |
spatie/laravel-data or phpdocumentor/type-resolver. |
| Twig Templates | Serve Swagger UI/ReDoc as static files or use Blade. |
| Validator Integration | Use Laravel’s Validator facade or mock Symfony’s Validator. |
Assessment Phase:
Proof of Concept (PoC):
composer require nelmio/api-doc-bundle.laravel-symfony-bundle) and test basic attribute parsing.Incremental Rollout:
#[ApiTags({"Users"})]).Route::get('/api/docs', [NelmioApiDocController::class])).Fallback Plan:
php artisan generate:openapi) using zircote/swagger-php.| Laravel Version | PHP Version | Nelmio Feasibility | Workarounds Needed |
|---|---|---|---|
| 8.0–8.39 | 8.0–8.1 | Low (PHP 8.1+ required) | Upgrade PHP or use rubix/attribute. |
| 8.40+ | 8.1+ | Medium (Symfony bridge needed) | Install laravel-symfony-bundle. |
| 9.0+ | 8.1+ | High (native attribute support) | Minimal; focus on route/controller mapping. |
| 10.0+ | 8.2+ | High | Leverage Laravel’s improved attribute reflection. |
How can I help you explore Laravel packages today?