andrew-gos/serializer
Extensible PHP 8.2+ serializer that normalizes arrays/objects and encodes to JSON or XML. Register custom normalizers and encoders via a configurable Serializer. Pure encoders avoid mutating input and handle XML duplication/circular references.
json_encode()/xml_encode() implementations with a standardized, extensible solution for consistent serialization across microservices.Avoid if:
json_encode() instead.Consider if:
"This package lets us replace fragmented, error-prone serialization code with a single, maintainable library—reducing tech debt and improving API/data consistency. For example, it automatically handles circular references in complex objects (like nested user hierarchies), which currently breaks our JSON exports. It’s also future-proof, supporting both JSON and XML for integrations with legacy systems. The MIT license and active development (recent 1.1.0 release) make it a low-risk choice."
*"Andrew-Gos/Serializer gives us a drop-in replacement for json_encode() with superpowers:
User::class → ['id' => $user->id, 'roles' => ...]).Migration path:
json_encode($data) with $serializer->serialize($data, 'json').Tradeoff: Slight learning curve for custom normalizers, but pays off in consistency."*
How can I help you explore Laravel packages today?