2017 © Pedro Peláez
 

library ramsey-uuid-normalizer

Symfony Normalizer and Denormalizer for ramsey/uuid

image

gamez/ramsey-uuid-normalizer

Symfony Normalizer and Denormalizer for ramsey/uuid

  • Thursday, August 31, 2017
  • by jeromegamez
  • Repository
  • 1 Watchers
  • 0 Stars
  • 573 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 3 % Grown

The README.md

Symfony Normalizer and Denormalizer for ramsey/uuid

Current version Supported PHP version Monthly Downloads Total Downloads Tests Sponsor, (*1)

Installation

The utility can be installed with Composer:, (*2)

$ composer require gamez/ramsey-uuid-normalizer

Usage

Symfony Serializer Component

The usage example requires the PropertyAccess Component component, which can also be installed with Composer:, (*3)

$ composer require symfony/property-access
use Gamez\Symfony\Component\Serializer\Normalizer\UuidNormalizer;
use Ramsey\Uuid\Uuid;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
use Symfony\Component\Serializer\Serializer;

class Person
{
    public $id;
    public $name;
}

$person = new Person();
$person->id = Uuid::uuid4();
$person->name = 'Jérôme Gamez';

$encoders = [new JsonEncoder()];
$normalizers = [new UuidNormalizer(), new ObjectNormalizer()];
$serializer = new Serializer($normalizers, $encoders);

$json = $serializer->serialize($person, 'json');
echo $json.PHP_EOL;
// {"id":"3d79048c-29e7-482f-979a-5b9a708b2ede","name":"J\u00e9r\u00f4me Gamez"}

$person = $serializer->deserialize($json, Person::class, 'json');
var_dump($person);
/*
class Person#27 (2) {
  public $id =>
  string(36) "3d79048c-29e7-482f-979a-5b9a708b2ede"
  public $name =>
  string(14) "Jérôme Gamez"
}
*/

For further information on how to use the Symfony Serializer Component, please see The Serializer Component in the official documentation., (*4)

The Versions

31/08 2017

dev-master

9999999-dev https://github.com/jeromegamez/ramsey-uuid-normalizer

Symfony Normalizer and Denormalizer for ramsey/uuid

  Sources   Download

MIT

The Requires

 

The Development Requires

uuid serializer symfony normalizer ramsey

31/08 2017

1.0

1.0.0.0 https://github.com/jeromegamez/ramsey-uuid-normalizer

Symfony Normalizer and Denormalizer for ramsey/uuid

  Sources   Download

MIT

The Requires

 

The Development Requires

uuid serializer symfony normalizer ramsey