spatie/value-object
Deprecated Spatie package for PHP 8+ data transfer objects. Create typed DTOs from arrays with casting, validation, and attribute mapping (e.g., nested keys). Consider migrating to spatie/laravel-data or cuyz/valinor.
DateTime, Collection) reduces boilerplate in controllers/services.spatie/laravel-data or cuyz/valinor) is recommended. This introduces technical debt risk if not addressed.spatie/laravel-data, this package is framework-agnostic, missing Laravel-specific integrations (e.g., Eloquent, Form Requests).cuyz/valinor.spatie/laravel-data/valinor is advisable.Illuminate\Support\Collection or raw arrays may suffice.spatie/laravel-data or valinor within [X] months? If not, a fork may be necessary.spatie/laravel-data is a better fit.valinor).spatie/laravel-data:
spatie/data-transfer-object with spatie/laravel-data (1:1 feature parity in most cases).->rule() → ->rules()).FormRequest support out of the box).$this->assertInstanceOf(MyDto::class, $result);
$this->assertEquals('expected', $result->property);
Request handlers with validated DTOs.// Before
$user = User::create(request()->all());
// After
$dto = new CreateUserDto(request->validate());
$user = User::create($dto->toArray());
// Before
return response()->json(['data' => $user->toArray()]);
// After
return response()->json(new UserResourceDto($user));
$command = new UpdateUserCommand($dto);
$this->dispatch($command);
spatie/data-transfer-object with spatie/laravel-data or a fork.->rule('required')).Spatie\DataTransferObject\Exceptions\InvalidPropertyType: Property 'age' must be of type int, string given.
| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Invalid input data | Validation fails early (good). | Use ->throwOnInvalid() or handle exceptions gracefully. |
| Missing DTO property | Runtime errors if not nullable. | Use ?int or default values in DTO definitions. |
| Migration to new package fails | Downtime if not planned. | Test migration in staging; use feature flags for gradual rollout. |
| Forked package breaks | Custom features stop working. | Maintain fork in a separate repo; test regularly. |
| Overuse of DTOs | Unnecessary complexity. | Reserve DTOs for cross-cutting concerns; avoid for trivial cases. |
How can I help you explore Laravel packages today?