tenantcloud/data-transfer-objects
A lightweight PHP package for defining typed data transfer objects, making it easy to move structured data between layers of your Laravel application with clear, validated, and reusable DTO classes.
Consider it when all of the following hold:
Look elsewhere — or build in-house — when any of the following apply, which is the default case here:
composer.lock is a supply-chain and upgrade-cost decision; this is a one-way door for the modules that depend on it.spatie/laravel-data, spatie/data-transfer-object, cerbero/dto, wendelladriel/validated-dto) offer validation integration, Laravel container/route-model binding, TypeScript generation, and documented upgrade paths. For a commodity capability like DTOs, the "buy" side of build-vs-buy has a clear winner and the differentiation available from a niche package is near zero.Recommendation: Do not add as a production dependency. Do evaluate as a design input alongside spatie/laravel-data, and default to the incumbent unless this package demonstrates a specific, load-bearing advantage you can articulate in one sentence.
To executives: We evaluated an open-source PHP library for structuring data as it moves between systems. It is technically reasonable but has essentially no adoption (4 GitHub stars, zero downstream dependents) and is maintained as a by-product of one company's internal product. Adopting it would make us the de facto maintainers of a component we don't want to own. The capability it provides is commodity — the market leader is well-supported and free. Recommendation: no new dependency, no budget impact; use it as a design reference and standardize on the established alternative. Net cost of the decision: near zero. Net risk avoided: an unsupported component in the critical path of every request.
To engineering: Read the source for the pattern, not for the install. It's a useful illustration of typed, immutable payloads replacing arrays at layer boundaries, and a sanity check on how little code a DTO layer actually requires. If we build in-house, scope it to 1–3 days against the criteria this package implies: constructor-time typing, array/JSON hydration, nested and collection support, and no framework coupling. If we buy, spatie/laravel-data is the default. Either way, the deliverable is a team convention on where DTOs live and what may not cross a boundary as an array — that convention is the actual value, and it is independent of this package.
How can I help you explore Laravel packages today?