PHP code example of mihai-stancu / serializer

1. Go to this page and download the library: Download mihai-stancu/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/ */

    

mihai-stancu / serializer example snippets


// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new MS\SerializerBundle\MSSerializerBundle(),
    // ...
);

$encoderName = array_rand(
    array(
        'bencode', 
        'bson', 
        'cbor',
        'export',
        'form',
        'igbinary',
        'ini',
        'msgpack',
        'rison',
        //'sereal',
        'serial',
        //'smile',
        'tnetstring',
        'ubjson',
        'yaml',
    )
);

$serializer = $container->get('serializer');
$string = $serializer->serialize($data, $encoderName);
$data = $serializer->unserialize($data, $class, $encoderName);