gbprod/uuid-normalizer
A Symfony Serializer normalizer for Ramsey UUIDs. Install via Composer, register UuidNormalizer and UuidDenormalizer as serializer.normalizer services, and serialize or deserialize UUIDs without "Not a time-based UUID" errors. Requires PHP 7.4+.
(string) casting scattered through controllers and resources.Normalizer/Denormalizer code plus the tests and edge cases (invalid UUID input, variant/version handling) that come with it. At this scope the decision is not strategic — it is a maintenance-cost decision, and the answer is to take the dependency if we already run Symfony Serializer.UuidInterface in the domain layer rather than raw strings — e.g., typed DTOs for request/response payloads, event payloads, or message-queue envelopes. This is the package's real enabling value: it removes the serializer friction that otherwise pushes teams back to string-typed IDs.UnsupportedOperationException: Not a time-based UUID) is a 500-level symptom of a missing normalizer. Adopting the package lets us define a deliberate 400/422 contract for malformed UUIDs instead of leaking 500s.symfony/serializer (common in DDD/hexagonal codebases, or where serialization is used for API versioning or message payloads); any PHP service where Ramsey UUIDs and Symfony Serializer coexist.HasUuids, uuid cast) and API Resources already handle UUID-to-string and string-to-UUID; this package adds nothing there and should not be presented as a Laravel serialization solution.Adopt when all of these hold:
ramsey/uuid for domain identifiers and symfony/serializer for request/response or message serialization in the same service.UnsupportedOperationException class of bug.Look elsewhere or skip when:
symfony/serializer is not the default serialization path, so the package solves a problem we do not have.ramsey/uuid's __toString and a route/attribute cast is sufficient; no normalizer required.WTFPL is a permissive but unusual license that will trip some legal/procurement reviews; 0 dependents and a single maintainer mean no ecosystem backstop. Budget for the (small) possibility of vendoring the two classes.Adoption checklist before merging: confirm the version is compatible with our symfony/serializer major, confirm the normalizer is registered with correct priority relative to other normalizers (ordering matters for how UuidInterface is matched), and add one contract test that asserts a malformed UUID produces our intended 4xx rather than a 500.
For executives: This is a small, low-risk open-source utility that removes a class of 500 errors and eliminates roughly a day of custom plumbing plus ongoing upkeep per service that models identifiers as UUID objects. It is not a platform decision or a strategic bet — it is a maintenance-cost reduction with a clear, narrow blast radius. Cost is a single Composer dependency; risk is limited to a permissively licensed, single-maintainer package that we could vendor in an afternoon if it were ever abandoned. Recommendation: approve for Symfony-serialized services; do not include in standard Laravel service templates.
For engineering: gbprod/uuid-normalizer supplies the UuidNormalizer/UuidDenormalizer pair that Symfony Serializer is missing, so UuidInterface properties on DTOs round-trip as canonical strings without hand-written normalizers. Register both under the serializer.normalizer tag, mind normalizer priority, and cover malformed input with an explicit 4xx assertion. Caveats: Symfony Serializer only — Laravel's cast/Resource path makes this redundant; the project is small (30 stars, 0 dependents, single maintainer) and WTFPL-licensed, so treat it as a vendorable two-class dependency rather than infrastructure. Pin the version and keep a contract test around UUID serialization so a future swap is a non-event.
How can I help you explore Laravel packages today?