Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Eloquent Serializer Laravel Package

theofidry/eloquent-serializer

A lightweight serialization layer for Laravel Eloquent models. Define dedicated serializer classes to control which attributes and relationships are exposed, then turn models, collections, and paginated results into clean arrays for APIs and JSON responses.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture fit: This release clarifies what the package actually is: a Laravel package (service provider with auto-discovery, ~5.5.0 Laravel constraint) that swaps Symfony Serializer in as the normalization/denormalization layer over Eloquent models. That corrects the prior framing—it is not a bridge for Symfony apps using Eloquent, it is an alternative serialization stack for Laravel apps that prefer Serializer's normalizer/encoder/context model over toArray/toJson, API Resources, and casts. The fit question therefore narrows to: do we have a Laravel application whose serialization requirements (context-driven groups, versioning, encoder negotiation, denormalization into models) genuinely exceed what API Resources provide? Laravel 5.5-era apps with heavy DTO/serialization needs were the design target. For any current Laravel application this remains architecturally redundant: first-party API Resources, model casts, and JsonResource cover the same ground with supported code. It is still a niche tool, just niche in a different direction than previously assessed.

Integration feasibility: The wiring got marginally easier—auto-discovery removes the manual provider registration, and the added Symfony normalizers mean the serializer service is more complete out of the box. But this release does not improve feasibility against a supported stack, it documents the ceiling. The constraints are now explicit and hard: PHP ^7.1, Laravel ~5.5.0 (caret-tilde, i.e. >=5.5.0 <5.6.0—not 5.6, not 6+, not 8/10/11/12), Symfony ^3.4 || ^4.0. Composer will refuse to install this alongside any current Laravel. It is a PHP 7.1 / Laravel 5.5 artifact, and the PHPUnit ^6.4 bump confirms the test suite is pinned to that era and will not run on modern PHPUnit without rework. Adoption still requires a fork or reimplementation; it just requires it more emphatically.

Technical risk: Unchanged at High, with the lifecycle evidence now stronger rather than weaker. A release that moves PHP from ^7.0 to ^7.1 and Laravel to ~5.5.0 is consolidation within an already-obsolete band, not modernization—there is still no PHP 8, no Laravel 6+, no Symfony 5+, and no getSupportedTypes() support. Secondary risks persist: denormalization is a mass-assignment surface requiring explicit attribute/relation allow-lists; recursive relation normalization invites N+1 queries and circular references; cast/date/hidden-visible semantics can diverge from native Laravel output and drift the API contract if this becomes the boundary. Added normalizers widen the surface slightly—more encoders/normalizers registered by default means more implicit behavior to audit.

Key questions:

  • Do we actually run Laravel 5.5.x on PHP 7.1–7.4? If not, this package is not installable and the decision is fork-versus-reimplement, full stop.
  • If we are on 5.5, what is forcing us off native API Resources—is there a real requirement (groups, context, encoder negotiation, denormalization) or an aesthetic preference?
  • Which of the newly added normalizers do we rely on, and do their default registrations match the output contract we need?
  • Are we prepared to fork, re-pin constraints to our PHP/Laravel/Symfony versions, and own the code permanently?
  • Do we need denormalization at all, or only read-side normalization? The former is the security-sensitive half.
  • Is the cost of hand-rolling an ObjectNormalizer subclass or a JsonResource equivalent lower than the fork? For a small normalizer, usually yes.

Integration Approach

Stack fit: Fit is now precisely bounded: a Laravel 5.5.x application on PHP 7.1–7.4 that has standardized on Symfony Serializer contracts. Outside that band—Laravel 5.6 through 12, or PHP 8.x—the package does not install. It remains a poor fit for greenfield Laravel, for Doctrine-based Symfony, and for teams without Serializer expertise.

Migration path: Adoption-by-fork only. Two routes: (1) vendor the package under our namespace, relax the ~5.5.0/^3.4||^4.0 constraints to our actual versions, port the normalizer interfaces to Symfony 5/6/7 (getSupportedTypes()), and assign an explicit owner; or (2) skip the dependency and implement the normalizer directly on AbstractNormalizer/ObjectNormalizer. Given the code is a few hundred lines and every line would need touching during a port anyway, route 2 remains the better trade—the fork's only lasting value is the Eloquent attribute/cast/relation traversal logic, which is the part most likely to need rewriting against modern Eloquent.

Compatibility: The release gives us a definitive floor and ceiling rather than removing uncertainty. Build the matrix as PHP 7.1–7.4 (as-shipped) versus PHP 8.1/8.2/8.3 (requires port), crossed with Laravel 5.5 (supported) versus 8/10/11/12 (requires port), crossed with Symfony Serializer 3.4/4.0 (supported) versus 5.4/6.x/7.x (requires port). Expect breakage first at the normalizer interface level, then at Eloquent attribute/cast/relation APIs, then in the test suite (PHPUnit 6.4 → 9/10).

Sequencing:

  1. Confirm our PHP/Laravel versions against the shipped constraints. If we are not on 5.5.x, treat this as "source to read," not "package to install," and skip to step 3.
  2. If we are on 5.5.x, spike: install via auto-discovery, run a representative model (relations, casts, hidden/visible, dates, nested collections) through normalize and denormalize on a branch.
  3. Decide fork versus reimplement based on spike friction and diff size—weighting that the port is mandatory regardless.
  4. Define the serialization contract with golden-file tests against the current production representation.
  5. Wire the serializer service; constrain denormalization to allow-listed attributes and relations; explicitly enumerate which of the newly bundled normalizers are enabled.
  6. Shadow-run and diff outputs before cutover, then retire the legacy serialization path.

Operational Impact

Maintenance: Total ownership, unchanged. Archived repository, no upstream patches, no PHP 8 or Symfony 5+ work, no CVE response. This release is the last known state: PHP 7.1, Laravel 5.5, Symfony 3.4/4.0, PHPUnit 6.4. Budget for dependency-bump reviews, interface-drift fixes, test-suite modernization, and security review of the denormalization path. Small code surface keeps steady-state cost low, but the test-suite pin means even running the existing tests on a modern toolchain is work.

Support: None externally. Twelve stars, zero dependents, no community, no Stack Overflow corpus, no upstream fixes to cherry-pick. The added documentation and Travis updates are internal housekeeping in a dead repo, not a support signal. Internal documentation and a named owner are prerequisites.

Scaling: Unchanged—CPU-bound object-graph traversal on Symfony Serializer, with reflection and metadata overhead. Watch lazy-loaded relation traversal firing queries during normalization (invisible N+1), and unbounded recursion on bidirectional relations. Cache normalizer metadata, eager-load explicitly before normalizing, set circular-reference and depth limits, and benchmark against native Laravel array conversion before committing high-volume endpoints. The newly registered default normalizers add a small fixed per-serialization cost worth measuring.

Failure modes:

  • Composer install failure or silent version conflict from the ~5.5.0 Laravel pin on any non-5.5 application.
  • Fatal errors after PHP/Symfony/Eloquent upgrades due to changed normalizer interfaces or attribute APIs.
  • Silent API contract drift from cast/date/hidden-field semantics diverging from native Laravel output.
  • Mass-assignment or unintended relation writes via unconstrained denormalization.
  • Unexpected behavior from newly added, implicitly registered normalizers.
  • Circular reference exhaustion or memory blowups on deeply nested models.
  • N+1 query storms from lazy relation traversal under load.
  • Bus-factor failure: the one engineer who understands the fork leaves.

Ramp-up: Low for engineers fluent in Symfony Serializer and Eloquent—half a day to read the code, one to two days to spike and write contract tests. Higher for Laravel-only teams unfamiliar with Serializer's normalizer/encoder/context model. The real cost is not learning the package; it is the organizational work of accepting permanent ownership of an archived, version-pinned dependency in exchange for a serialization convenience that first-party Laravel facilities already largely provide.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
socialdept/atp-orm
cboxdk/laravel-assistant-client
socialdept/atp-resolver
socialdept/tenant-domains
tautvydasr/blade-class-names
socialdept/color-scales
maherelgamil/controller
coleus/widgets
coleus/table
coleus/users
coleus/music
coleus/health
coleus/calendar
coleus/notes
coleus/support
coleus/settings
coleus/apps
seampact/laravel
emmyconceptng/laravel-ng-postcode
jjsquady/round-robin