PHP code example of opensoft / opensoft-simple-serializer-bundle
1. Go to this page and download the library: Download opensoft/opensoft-simple-serializer-bundle 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/ */
opensoft / opensoft-simple-serializer-bundle example snippets
// in AppKernel::registerBundles()
$bundles = array(
// ...
new Opensoft\Bundle\SimpleSerializerBundle\OpensoftSimpleSerializerBundle($this),
// ...
);
// in AppKernel::registerBundles()
$bundles = array(
// ...
new Opensoft\Bundle\SimpleSerializerBundle\OpensoftSimpleSerializerBundle($this),
// ...
);
// app/autoload.php
$loader->registerNamespaces(array(
// ...
'Opensoft' => __DIR__.'/../vendor/bundles',
'Opensoft\\SimpleSerializer' => __DIR__.'/../vendor/simple-serializer/src',
// ...
));
//serialization
$serializer = $container->get('simple_serializer');
$string = $serializer->serialize($object);
//Serialize array of the objects
$string = $serializer->serialize(array($object));
//Serialize specific groups
$serializer->setGroups(array('get'));
$string = $serializer->serialize($object);
//Serialize specific version
$serializer->setVersion('1.0');
$string = $serializer->serialize($object);
//deserialization
$object = $serializer->unserialize($jsonData, $object);
//Unserialize array of the objects
$objects = $serializer->unserialize($jsonData, array($object));
//Unserialize specific groups
$serializer->setGroups(array('get'));
$object = $serializer->unserialize($jsonData, $object);
//Unserialize specific version
$serializer->setVersion('1.0');
$object = $serializer->unserialize($jsonData, $object);
//Strict unserialize mode
$serializer->setStrictUnserializeMode(2);
$object = $serializer->unserialize($jsonData, $object);
//Medium Strict unserialize mode
$serializer->setStrictUnserializeMode(1);
$object = $serializer->unserialize($jsonData, $object);
//Non-Strict unserialize mode
$serializer->setStrictUnserializeMode(0);
$object = $serializer->unserialize($jsonData, $object);
bash
$ php composer.phar update
bash
$ php bin/vendors install