baptiste-contreras/symfony-request-param-bundle
#[DtoRequestParam]) ensures modern PHP practices, reducing friction for teams already adopting PHP 8.1+.#[Route]). Porting this logic to Laravel would require significant refactoring or a custom wrapper.DtoProviderDriverInterface) suggests extensibility for custom source types (e.g., XML, form data).Illuminate\Http\Request, form requests, or manual binding) differs fundamentally from Symfony’s. Replicating this functionality would require:
DtoProviderDriverInterface and related logic to work with Laravel’s Request object.#[RequestParam] with a custom Laravel attribute reader).Validator facade).dto-builder package) that both frameworks can consume, rather than porting the entire bundle.Validator facade) would require significant adaptation.sourceType (e.g., JSON, form data) would need Laravel-compatible implementations, increasing development time.symfony/validator, symfony/dependency-injection) would need replacements in Laravel, adding technical debt.spatie/laravel-data)?spatie/laravel-data for DTOs)?#[Route]).Illuminate\Http\Request, Illuminate\Validation\Validator) is fundamentally different. Key mismatches:
Route::get/post or controller methods with $request injection, not Symfony’s #[Route].Illuminate\Container\Container) doesn’t natively support Symfony’s AutoProvideRequestDto logic.AutoProvideRequestDto with a Laravel service provider or middleware.#[RequestParam]) and parse them manually or via a package like php-attributes.DtoProviderDriverInterface to work with Laravel’s Request object.| Step | Symfony | Laravel (Hypothetical Port) |
|---|---|---|
| 1. Installation | composer require baptiste-contreras/symfony-request-param-bundle |
Custom composer package or fork with Laravel-specific logic. |
| 2. Configuration | Bundle enablement in config/bundles.php |
Register service provider in config/app.php, publish config if needed. |
| 3. Controller Setup | Add #[AutoProvideRequestDto] and #[DtoRequestParam] attributes. |
Replace with custom attributes (e.g., #[RequestParam]), or use method injection with manual binding. |
| 4. DTO Definition | Use Symfony’s Validator and Serializer components. |
Replace with Laravel’s Validator and custom deserialization logic. |
| 5. SourceType Handling | Extend DtoProviderDriverInterface for custom formats. |
Implement Laravel-compatible drivers (e.g., JsonDriver, FormDriver). |
| 6. Validation | Leverage Symfony’s validation groups. | Map to Laravel’s validation rules or use a shared validation library. |
RequestStack vs. Laravel’s Request object.Constraint system vs. Laravel’s rule-based validation.Attribute reader vs. Laravel’s lack of built-in attribute routing.For a Laravel port, prioritize the following steps:
#[RequestParam] attribute parser (e.g., using reflection or php-attributes).DtoProvider that constructs DTOs from Laravel’s Request.Validator::make().Request methods (e.g., json(), all()).laravel-request-param) with clear documentation.symfony/validator updates).How can I help you explore Laravel packages today?