mhujer / jms-serializer-uuid
Uuid serializer and deserializer for JMS Serializer library
Installs: 981 424
Dependents: 4
Suggesters: 0
Security: 0
Stars: 29
Watchers: 3
Forks: 8
Open Issues: 0
Requires
- php: ~8.0
- jms/serializer: ~3.14
- ramsey/uuid: ~3.0|~4.0
Requires (Dev)
- consistence-community/coding-standard: 3.11.1
- php-coveralls/php-coveralls: 2.5.2
- php-parallel-lint/php-parallel-lint: 1.3.1
- phpunit/phpunit: 9.5.10
README
This library allows you to serialize and deserialize ramsey/uuid UUIDs when using JMS Serializer library.
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 in services.yaml
:
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 8.0 or higher.
Submitting bugs and feature requests
Bugs and feature request are tracked on GitHub
Author
Changelog
3.4.1 (2021-12-07)
- #17 handle non-stringable values
3.4.0 (2021-11-05)
3.3.0 (2020-12-31)
3.2.0 (2020-05-17)
- #10 Add support for ramsey/uuid v4 (thank you @simPod!)
3.1.0 (2019-05-31)
3.0.0 (2018-11-27)
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