Illuminate\Http\Request), validation (Illuminate\Validation), and form requests. Complements packages like spatie/laravel-data or vinkla/hashids for structured input handling.symfony/serializer); requires upfront DTO definition.Illuminate\Foundation\Http\FormRequest via hydrate() method.Request->only()/except() calls or array_merge() hacks.Illuminate\Http\Resources\Json\JsonResource) for output hydration (though the package focuses on input).Psr\Http\Message\ServerRequestInterface with minor adapter layer (e.g., zend-expressive).where() clauses.azjezz/input-hydrator-legacy).static::hydrate() for singleton patterns.respect/validation.PHPUnit data providers for DTO test matrices.FormRequest) interact with hydrators? Will hydrators pre-filter data?| Component | Fit Level | Notes |
|---|---|---|
| Laravel Controllers | ✅ High | Replaces Request->input() with Hydrator::hydrate($request) |
| Form Requests | ✅ High | Extend FormRequest to hydrate DTOs in authorize() or rules() |
| API Resources | ⚠️ Medium | Not primary use case, but can hydrate input for resource creation |
| Queues/Jobs | ✅ High | Hydrate DTOs from serialized payloads (e.g., JobPayload::fromRequest()) |
| CLI Artisan Commands | ⚠️ Low | Overkill for CLI; manual parsing may suffice |
| Livewire/Inertia | ❌ No | Frontend frameworks handle input differently; hydrators add no value |
CreateUserRequestDTO) and hydrate in controllers:
public function store(CreateUserRequest $request) {
$dto = CreateUserRequestDTO::hydrate($request);
// Use $dto->email, $dto->password (immutable, validated)
}
FormRequest to hydrate DTOs in withValidator():
public function withValidator() {
$dto = $this->hydrate(CreateUserRequestDTO::class);
$this->validator->after(function ($validator) use ($dto) {
// Post-hydration validation
});
}
Request->only()/except() calls.HydrateUserRequestTest).laravel/framework version constraints in composer.json.$dto = SearchQueryDTO::hydrate($request);
User::where('name', 'like', "%{$dto->query}%")->get();
CreateOrderRequestDTO).Request->input() calls.Request->only() calls.v1, v2).Xdebug to inspect DTOs during debugging.phpdoc or custom scripts.spatie/laravel-data if community support is a priority.How can I help you explore Laravel packages today?