juststeveking/laravel-data-object-tools
Handy tools and helpers for working with data objects in Laravel. Simplifies creating, validating, transforming, and casting DTOs, helping you keep application data flow clean, type-safe, and consistent across your codebase.
spatie/laravel-data, or an internal Artisan generator plus a written DTO convention doc. At 66 stars, zero dependents, and a single maintainer, we are not buying a supported product — we are buying a pattern with a head start on scaffolding. A short internal generator is a credible substitute if DTO scope stays narrow, so price this as "hours saved per team" rather than "capability acquired."Adopt when:
composer.json — not inferred from release notes.Look elsewhere or defer when:
^1.1.0 is possible but splits the estate into two DTO dialects for no product benefit.spatie/laravel-data is the mature alternative with a community behind it.fromArray() static method suffice. Be honest about this; it is the most common correct answer.Mandatory gate before rollout: read the 2.0.0 composer.json directly. A semver-major whose entire changelog reads "Support for Laravel 11" almost certainly dropped Laravel 9/10 and may have raised the PHP floor. An incomplete changelog on a major version is the one item to close out before scheduling — not a reason to reject, but a reason to verify. Second gate, equally important: confirm in writing whether generated DTOs inherit from the package base class or stand alone. If they inherit, a future major invalidates existing classes and our blast radius grows materially.
To executives: This is a small, zero-runtime, MIT-licensed developer tool that reduces boilerplate when moving data between layers of a Laravel application. Three things to know. One, the 2.0 release is a major version, which in practice means older Laravel versions are dropped — so it is only relevant to us once we are on Laravel 11, and it rides that upgrade rather than leading it. Two, it is maintained by a single developer, so we treat it as a pattern we can absorb rather than a platform we depend on. Three, the cost is a Composer line item plus hours of ramp-up per developer, and the risk is low and reversible: no runtime surface, no data, no on-call exposure, and if upstream goes quiet we vendor a small base class and carry on. Recommendation: adopt as part of the Laravel 11 upgrade, not ahead of it, and standardise on one DTO convention across the estate rather than letting teams pick.
To engineering: Low-coupling Artisan generators plus a base data-object class; nothing runs on the request path. Install with composer require juststeveking/laravel-data-object-tools:^2.0 on Laravel 11 apps; explicitly pin ^1.1.0 where 2.0 won't resolve so upgrades fail loudly instead of drifting. The 1.1.0 → 2.0.0 delta is almost certainly a composer.json constraint change rather than feature work, so treat it as such: verify constraints, bump, regenerate one representative DTO, and diff it against an existing one — the cheapest BC-break detector we have. Standardise on one base class and one hydration convention; running this alongside spatie/laravel-data in the same app produces ambiguous hydration semantics, so make that choice deliberately per app. Validate before hydration, keep toModel()/toAttributes() explicit where persistence rules matter, and serialise through API Resources rather than exposing objects. The real risk is not churn but dormancy — so keep the DTO convention documented in our own repo, add a CI check on generated shape before more than two teams adopt it, and plan on the assumption that we could fork the base class if upstream goes quiet. Ramp-up is hours per developer; the conventions doc carries more of the value than the package does.
How can I help you explore Laravel packages today?