czim/laravel-dataobject
Lightweight data objects for Laravel: define typed properties, hydrate instances from arrays, and convert them back to arrays or JSON. A simple way to keep request, config, and domain data structured, consistent, and easy to pass around with minimal boilerplate.
DataObject/Dto base class in-house. This package is best framed as a starting point and reference implementation, not a strategic dependency — it lets you evaluate the shape of a DTO layer in days rather than weeks.$payload['foo'] throughout the app.Consider it when:
Look elsewhere when:
spatie/laravel-data is the mature, widely adopted option for that surface area.readonly classes, constructor property promotion, and enums cover a large share of the DTO use case with zero dependency. That is often the correct build-vs-buy answer and should be evaluated first.Recommended posture: treat this as a spike candidate, not an adoption decision. Budget a one-to-two day evaluation against the native-PHP baseline and spatie/laravel-data, then decide between (a) copy the pattern into an in-house base class, or (b) adopt a maintained package.
For executives — the business case in one paragraph: This is a small, free, MIT-licensed utility that standardizes how data moves between parts of our application. The value is defect reduction and velocity: typed, self-describing data objects catch integration errors at development time instead of in production, and they make future work — public APIs, partner integrations, service extraction — measurably cheaper. Cost is near zero and the code is small enough to own outright if the upstream project stalls. The honest caveat: it has a single maintainer and negligible community, so we should not depend on it as infrastructure. Recommendation is a short, time-boxed spike, with the likely outcome being that we adopt the pattern internally rather than the package as a long-term dependency.
For engineering — the practical summary:
readonly classes, in an afternoon per usage site.readonly classes and (2) spatie/laravel-data. Decide on the pattern first, the package second.How can I help you explore Laravel packages today?