digital-craftsman/self-aware-normalizers
Adopt When:
Look Elsewhere If:
"This package lets our domain models ‘speak for themselves’ when converting to/from APIs or databases. Instead of writing separate serializers or mappers—which can drift from the domain—our value objects handle their own normalization. This reduces technical debt, speeds up API evolution, and aligns with our DDD strategy. For example, if our Order object needs to mask customer emails in APIs but not in internal storage, the logic stays with the object, not scattered across controllers or serializers. It’s a small investment now that pays off in maintainability as we scale."
Key Outcomes:
*"This is a Symfony bundle (works in Laravel via Symfony components) that adds two interfaces to value objects/DTOs:
SelfNormalizable – Converts the object to scalar data (e.g., ['id': 123, 'name': 'Foo']).SelfDenormalizable – Rebuilds the object from scalar data.Why use it?
Serializer::normalize($order) with $order->normalize().User DTO’s structure changes, the normalization updates automatically.Trade-offs:
Proposal: Pilot this in our Orders module for API responses. If it reduces serializer bugs by 30% (as seen in similar projects), we’ll roll it out to other DTOs."*
Demo: Show a before/after of a UserDTO with/without self-normalization. Highlight how the object’s normalize() method replaces a 20-line serializer class.
How can I help you explore Laravel packages today?