Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mhujer/jms-serializer-uuid

Uuid serializer and deserializer for JMS Serializer library
https://github.com/mhujer/jms-serializer-uuid

Last synced: about 1 month ago
JSON representation

Uuid serializer and deserializer for JMS Serializer library

Awesome Lists containing this project

README

        

# UUID support for JMS Serializer

[![Latest Stable Version](https://poser.pugx.org/mhujer/jms-serializer-uuid/version.png)](https://packagist.org/packages/mhujer/jms-serializer-uuid) [![Total Downloads](https://poser.pugx.org/mhujer/jms-serializer-uuid/downloads.png)](https://packagist.org/packages/mhujer/jms-serializer-uuid) [![License](https://poser.pugx.org/mhujer/jms-serializer-uuid/license.svg)](https://packagist.org/packages/mhujer/jms-serializer-uuid) [![Coverage Status](https://coveralls.io/repos/github/mhujer/jms-serializer-uuid/badge.svg?branch=master)](https://coveralls.io/github/mhujer/jms-serializer-uuid?branch=master)

This library allows you to serialize and deserialize [ramsey/uuid](https://github.com/ramsey/uuid) UUIDs
when using [JMS Serializer library](https://github.com/schmittjoh/serializer).

Usage
----
1. Install the latest version with `composer require mhujer/jms-serializer-uuid`
2. Register a custom handler to JMS Serializer ([documentation](https://jmsyst.com/libs/serializer/master/handlers))

```php
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 in `services.yaml`:

```yml

Mhujer\JmsSerializer\Uuid\UuidSerializerHandler:
tags:
- { name: jms_serializer.subscribing_handler }

```

Then you can use the `uuid` type for serialization or deserialization:

```php