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
Jms Serializer Uuid Bundle

Jms Serializer Uuid Bundle Laravel Package

mhujer/jms-serializer-uuid-bundle

Symfony bundle that integrates ramsey/uuid with JMS Serializer, registering handlers to serialize and deserialize UUID objects—including uuid-doctrine types—so your JSON APIs handle UUIDs cleanly without custom visitors.

View on GitHub
Deep Wiki
Context7

A Symfony bundle that adds ramsey/uuid support to JMS Serializer. It registers a custom handler so Uuid objects are transparently converted to strings during serialization and back into Uuid instances during deserialization—no custom handlers or DTO workarounds needed.

  • Serializes UuidInterface objects to plain strings
  • Deserializes strings back into Uuid instances
  • Integrates automatically via Symfony's DI container
  • Compatible with existing JMS Serializer type mappings
  • Removes boilerplate from UUID-heavy APIs and DTOs
Frequently asked questions about Jms Serializer Uuid Bundle
Does mhujer/jms-serializer-uuid-bundle work in a Laravel application?
No. This is a Symfony bundle, not a Laravel package, and its value is Symfony-specific wiring: the Bundle class, DependencyInjection extension, services.xml definition and compiler pass are all inert outside a Symfony kernel. Only the single handler class that implements SubscribingHandlerInterface is portable, and it is on the order of a few dozen lines. For a Laravel codebase the correct decision is to treat the repository as a reference implementation and write or vendor that handler yourself rather than pulling the bundle in.
Can I install mhujer/jms-serializer-uuid-bundle with Composer today?
Almost certainly not without modification. The last release was published on 2016-06-02 and targets the PHP, Symfony 2.7/3.0, jms/serializer 1.x and ramsey/uuid 2.x era, so Composer resolution will fail against modern PHP constraints such as PHP 8.1+ together with jms/serializer ^3 and ramsey/uuid ^4. Even if you pin your way around the constraints, you end up with an unowned fork inside vendor/ that a later composer update silently reverts. Add it to composer.json only if you are frozen on legacy Symfony and legacy PHP.
Which Symfony, JMS Serializer and ramsey/uuid versions does this bundle target?
It was built for Symfony 2.7 and 3.0 with jms/serializer around the 1.x line and ramsey/uuid 2.x. Since then JMS Serializer has moved from annotation metadata to attributes and changed its handler and graph-navigator signatures, while ramsey/uuid moved from static factories like Uuid::uuid4() to UuidInterface and Uuid::fromString() with relocated exception classes. Expect meaningful API drift on both sides, so budget rewrite time rather than a drop-in upgrade.
What exactly is inside this package?
The functional surface is tiny: one handler implementing SubscribingHandlerInterface that converts Ramsey\Uuid objects to their canonical string form and back, one DI extension, and a service definition, plus the usual Symfony bundle scaffolding. There is no business logic, no persistence layer and no runtime infrastructure. That small footprint is precisely why copying the handler into your own codebase is usually cheaper than depending on the package.
Is mhujer/jms-serializer-uuid-bundle still maintained and safe for production?
It is archived, the last release dates to June 2016, and it has roughly 12 stars and no dependents, so nobody is validating it against modern PHP or answering issues. As a dependency it carries severe risk because there is no maintainer to ship patches and no downstream ecosystem to surface regressions. As source material the risk is low: the MIT license makes vendoring, modifying and redistributing the handler legally clean, which is the strongest signal in the whole evaluation.
How do I serialize a ramsey/uuid UUID to a string in Laravel without this bundle?
In Laravel you rarely need a JMS Serializer handler at all. An Eloquent cast plus an API Resource typically covers both directions: store the UUID as a string column, cast it on the model, and cast the string back with Uuid::fromString() when you need the value object. If you prefer a plain string on the wire, casting the UUID object with (string) or calling toString() in your resource layer is enough. Introducing JMS Serializer just to handle UUIDs adds a dependency to solve a problem you should not have.
What if JMS Serializer is already a required dependency in my project?
Then the pragmatic path is to vendor the handler into your own application code, adjust it for the current jms/serializer version, and register it explicitly in your serializer configuration. That is a one to two day task and leaves you owning the code rather than depending on an abandoned repository. Do not install the bundle as-is and patch around it, because the patch lives in vendor/ and disappears on the next update.
Which UUID wire format does the handler produce?
It serializes UUID objects to their canonical string form and deserializes that string back into a Ramsey\Uuid object, but the exact contract is yours to define. You need to decide between RFC 4122 lowercase hyphenated, uppercase, braced, urn:uuid: prefixed, compact, and how nil UUIDs are treated, because changing that later breaks consumers. If persisted payloads in queues, event logs or third-party APIs were already produced by this handler, plan a dual-read period for backward compatibility.
What are the alternatives to using this bundle for UUID handling?
On Laravel, use Eloquent casts and API Resources, or build a small custom normalizer if you need one; there is no reason to route UUIDs through JMS Serializer. On Symfony, the framework's native Uid normalizer replaces this bundle entirely on supported versions. ramsey/uuid itself also offers serialization helpers, so check what your existing stack already gives you before adding anything new.
How should I test UUID serialization and deserialization if I vendor the handler?
Write an acceptance test that round-trips a UuidInterface through your serializer and asserts the exact string produced, asserting an equivalence check on the way back rather than object identity. Add cases for malformed input, an empty or null value, and the nil UUID, since those are where UUID handlers usually break. If you run a dual-read migration, add a case for each format you still accept so the compatibility window is covered by the suite. Keep these tests in your own repository so they travel with the vendored code.
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.
diephp/sequences
users-au/socialite-provider
twidpay/twid-logger
mrnewport/laravel-plaid
mrnewport/laravel-repo
mrnewport/laravel-docsign
mrnewport/laravel-stow
mrnewport/laravel-flow
mrnewport/laravel-priceable
mrnewport/laravel-nestedterms
fredmeng/laravel-apidoc-generator
itstructure/laravel-multilingual-tools
pdustdar/elasticsearch
markupai/php-sdk
rlacerda83/lumem-microservice-shipment
uni-method/symfony-lib
tacticmedia/scim-server-bundle
neika-ai/symfony-bundle
mattleads/agent-publishing-bundle
glavweb/framework-bundle