crell/serde
Crell/Serde is a fast, attribute-driven serialization and deserialization library for PHP. Map objects to JSON, YAML, CSV, and more with typed properties, nested structures, enums, and flexible field naming—no boilerplate.
Architecture fit. crell/serde is a standalone, attribute-driven serialization layer for PHP 8 — you annotate typed DTO properties/constructor parameters (e.g. #[Field], #[SerializeAs]) and the library hydrates and extracts them across formats (JSON, YAML, CSV). That makes it a strong fit as a boundary layer: typed DTOs for queue payloads, webhook ingestion, third-party API responses, and config objects. It is explicitly not a replacement for Eloquent persistence, API Resources, or Laravel's validation pipeline, and it does not know about the framework at all. Architecturally that decoupling is an asset — the same DTO contracts can be shared with non-Laravel PHP services in the same estate — but it also means every Laravel-specific concern (DI wiring, error → HTTP 422 mapping, config) is ours to build.
Integration feasibility. Low effort. composer require crell/serde, no service provider required, no published config, no framework bootstrapping. A useful pattern is a thin app/Serialization adapter (one or two classes) so application code depends on our interface rather than the package directly. Realistic spike: half a day to a day for a mid-level engineer to prove a round-trip on one real payload.
Technical risk.
NOASSERTION — the single hard blocker. Legal/Procurement must confirm the actual terms before this ships in a product. Treat as unresolved until signed off.symfony/serializer (bundled optionally with Laravel) or spatie/laravel-data (Laravel-native, far larger community).DateTime behavior need explicit testing — those are the behaviors most likely to surprise and the ones that turn into production data bugs.Key questions for the team.
toArray()/API Resources, spatie/laravel-data, or symfony/serializer — and what concrete gap does serde close that the baseline does not?Stack fit. PHP 8.1+ / Laravel 9–11 align with serde's requirements; no conflicts at the framework level. The intended split is clean: Eloquent owns persistence and relationships, serde owns typed transport contracts — job payloads, integration DTOs, event/message bodies. It also plays well with multi-format ingestion (JSON from one vendor, CSV from another) since the mapping is format-agnostic and defined once on the DTO.
Migration path. Do not retrofit. Introduce serde on greenfield boundaries only — pick one real integration (a webhook consumer or a queued job payload) and leave existing API Resources and Eloquent casts untouched. Wrap usage in a small application-level adapter so a future swap to symfony/serializer or spatie/laravel-data is a single-file change rather than a codebase-wide refactor. This keeps the decision reversible and cheap to unwind.
Compatibility. Verify in a sandbox: enum and backed-enum round-tripping; DateTimeImmutable handling and timezone fidelity; float/null/empty-array-vs-empty-object JSON fidelity; nested object and array-of-object hydration; constructor promotion with required vs optional parameters. Check for attribute-name collisions with any packages already using PHP attributes in the same classes.
Sequencing.
Maintenance. Single-maintainer dependency means we own continuity: pin exact versions, commit the lockfile, watch upstream releases, and set a documented trigger for vendoring or forking. The API surface is small, so upgrade churn should be modest — but "should be" is the operative phrase.
Support. No commercial support; GitHub issues only. The team owns the abstraction, the error semantics, and the documentation. Without enforced conventions, serde usage tends to fragment into per-team dialects of attribute naming and strictness settings — write the convention down early.
Scaling. The library is stateless, so horizontal scaling is unaffected. The risk is per-request overhead from class/attribute metadata resolution: cache mappers, avoid cold-path hydration in hot loops, and benchmark nested/large payloads explicitly. Typical Laravel request volumes should be comfortable; high-throughput batch ingestion needs numbers before commitment.
Failure modes.
"1" → 1, "false" → truthy) — enable strict behavior and test it.Ramp-up. Low. Attribute-based mapping is immediately legible to anyone who has used Symfony Serializer or Laravel casts — roughly 1–2 days for a mid-level developer to become productive. The genuine learning curve is not the API but the strictness and error semantics, plus format-specific edge cases. Seeding the repo with three or four canonical example DTOs and their tests will compress onboarding more than any documentation.
How can I help you explore Laravel packages today?