UUID support for JMS Serializer
This library allows you to serialize and deserialize ramsey/uuid UUIDs when using JMS Serializer library.
There is a Symfony Bundle for using this library in a Symfony application.
Usage
- Install the latest version with
composer require mhujer/jms-serializer-uuid
- Register a custom handler to JMS Serializer (documentation)
<?php
$builder
->configureHandlers(function(JMS\Serializer\Handler\HandlerRegistry $registry) {
$registry->registerSubscribingHandler(new \Mhujer\JmsSerializer\Uuid\UuidSerializerHandler());
})
;
or if you are using Symfony, register it as a tagged service:
mhujer.jms_serializer.uuid.uuid_serializer_handler:
class: Mhujer\JmsSerializer\Uuid\UuidSerializerHandler
tags:
- { name: jms_serializer.subscribing_handler }
Then you can use the uuid
type for serialization or deserialization:
<?php
use JMS\Serializer\Annotation as JMS;
class User
{
/**
* @JMS\Type("uuid")
* @var \Ramsey\Uuid\UuidInterface
*/
public $id;
}
Requirements
Works with PHP 5.6 or PHP 7.
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub
Author
Changelog
1.0.1 (2016-08-22)
- #1 fixed serialization to XML
1.0.0 (2016-05-28)
- initial release