PHP code example of remi-san / serializer

1. Go to this page and download the library: Download remi-san/serializer library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

remi-san / serializer example snippets


$classMapper = new RemiSan\Serializer\Mapper\DefaultMapper(
    new RemiSan\Serializer\NameExtractor\DefaultNameExtractor()
);
$classMapper->register(RemiSan\Serializer\Sample\MySampleClass::class);

$serializer = new RemiSan\Serializer\Serializer(
    $classMapper,
    new RemiSan\Serializer\Hydrator\HydratorFactory(__DIR__ . '/proxies', true),
    new RemiSan\Serializer\Formatter\FlatFormatter(),
    new Doctrine\Instantiator\Instantiator()
);

$object = new MySampleClass(new MySampleClass());
$serialized = $serializer->serialize($object);
$deserialized = $serializer->deserialize($serialized);