/jms-serializer-uuid

Uuid serializer and deserializer for JMS Serializer library

Primary LanguagePHPMIT LicenseMIT

UUID support for JMS Serializer Build Status

Latest Stable Version Total Downloads License Coverage Status

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

  1. Install the latest version with composer require mhujer/jms-serializer-uuid
  2. 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 7.2 or higher.

Submitting bugs and feature requests

Bugs and feature request are tracked on GitHub

Author

Martin Hujer

Changelog

3.0.0 (2018-11-27)

  • #6 dropped support for PHP 7.1 as it is no longer supported
  • #7 Require jms/serializer 2.0

2.0.0 (2018-01-05)

  • #3 require PHP 7.1, potential BC breaks because of added type-hints

1.0.1 (2016-08-22)

  • #1 fixed serialization to XML

1.0.0 (2016-05-28)

  • initial release