dualmedia/symfony-request-dto-bundle
Symfony-Centric: The package is tightly coupled with Symfony’s ecosystem (e.g., Doctrine ORM, NelmioApiDoc, Validator), making it a poor fit for Laravel without significant abstraction or middleware layers. Laravel’s request handling (e.g., Illuminate\Http\Request) differs fundamentally from Symfony’s RequestStack and ParameterBag system.
DTO Pattern Alignment: Laravel already has robust DTO support via:
Illuminate\Foundation\Http\FormRequest) for validation/transformation.Illuminate\Http\Resources\Json\JsonResource) for structured responses.$request->merge(['field' => (int)$request->field])).spatie/laravel-data or beberlei/assert for stricter typing.Doctrine Integration: Laravel’s Eloquent ORM is the de facto standard, but it lacks Symfony’s #[FindOneBy] annotations. Workarounds exist (e.g., custom query scopes or #[Attribute]-based macros), but they’d require custom development.
ParameterBag logic for Laravel’s Request object.#[FindOneBy] with query builder macros).darkaonline/l5-swagger or zircote/swagger-php).ResolvedDtoEvent) would need custom middleware.EventDispatcher vs. Laravel’s Events system.EntityManager vs. Eloquent’s Model system.spatie/laravel-data for DTOs + beberlei/assert for validation.Request::macro('dto', fn() => ...)) for lightweight DTO parsing.laravel-request-dto) be viable?Illuminate\Http\Request for DTO parsing.spatie/laravel-data: For immutable DTOs with validation.beberlei/assert: For runtime type checking.nunomaduro/collision: For cleaner attribute-based validation (similar to Symfony’s #[Assert]).Events can replace Symfony’s ResolvedDtoEvent for custom logic.DtoResolutionMiddleware could parse requests into DTOs before controllers.#[Bag]-like attributes from request data).spatie/laravel-data + custom validation rules for a subset of features.darkaonline/l5-swagger to document DTOs manually or via annotations (e.g., #[OpenApi\Property]).#[FindOneBy] with Eloquent query scopes or macros:
use Illuminate\Database\Eloquent\Builder;
Builder::macro('findByDto', fn (Builder $query, array $attributes) => ...);
Validator supports Symfony-like constraints via nunomaduro/collision or custom rules.ResolvedDtoEvent to Laravel’s DtoResolved event:
event(new DtoResolved($dto, $request));
422 Unprocessable Entity).spatie/laravel-graphql instead of DTOs.| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid DTO structure | 500 errors or silent failures |
Return 422 with detailed validation errors. |
| Doctrine/Eloquent mismatch | Broken entity loading | Fallback to manual queries or soft |
How can I help you explore Laravel packages today?