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.
Architecture fit
czim/laravel-dataobject is a thin inheritance-based framework for DTOs (data transfer objects): an abstract DataObject base, a DataObjectFactory, attribute casting hooks, and array access/fill helpers. It fills the gap between raw associative arrays and Eloquent models — the "structured payload crossing layer boundaries" slot (form requests → services → jobs → API resources).DataObject, not compose it. That is acceptable in small/medium Laravel apps but is at odds with the direction of modern PHP (readonly classes, constructor promotion, spatie/laravel-data, Symfony Serializer). Expect friction if the team prefers composition or attributes over inheritance.Integration feasibility
composer.json constraints (PHP and illuminate/*) will be the first thing to verify against the target stack; if the app is on Laravel 9/10/11 or PHP 8.1+, expect install conflicts or silent runtime breakage.czim/laravel-casting (the attribute casting engine) adds a second unmaintained surface with the same version-constraint risk.Technical risk
DataObject couples domain classes to the package's base class; a later migration means touching every DTO.Key questions
illuminate/* versions does composer.json actually allow, and does the test suite run against them?spatie/laravel-data / native readonly DTOs already solve better?Stack fit
czim ecosystem, or for a small internal tool where the cost of a fork is trivial.spatie/laravel-data covers the same ground with active maintenance, attribute-driven validation/casting, and Laravel-first ergonomics; PHP 8.1+ readonly classes cover the minimal case with zero dependencies. Recommend the alternatives unless there is a specific reason (existing code, migration cost) to prefer this package.Migration path
PayloadInterface) and let DataObject subclasses implement them. Controllers, jobs, and services depend on the interface, never on Czim\DataObject\DataObject. This keeps a future swap to spatie/laravel-data or native DTOs to a mechanical, test-guarded refactor.DataObject leak into public APIs, event payload contracts, or persisted schemas.Compatibility
composer why-not against the target Laravel/PHP matrix during the POC, not after commitment.spatie/laravel-data-style attribute usage, Laravel's own casting, and any ArrayAccess/JsonSerializable assumptions that collide with framework serialization.Sequencing
Maintenance
Support
Scaling
spatie/laravel-data, Laravel FormRequests).Failure modes
toArray/jsonSerialize output changes across versions or interacts badly with API resources and queue payloads.composer.lock, a fork mirror, characterization tests, and an interface-based escape hatch.Ramp-up
toArray). One pairing session should suffice.spatie/laravel-data or native readonly DTOs.How can I help you explore Laravel packages today?