PHP code example of alebediev / serializer
1. Go to this page and download the library: Download alebediev/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/ */
alebediev / serializer example snippets
use ALebediev\Serializer\{JsonSerializer, XmlSerializer, YamlSerializer};
...
$jsonSerializer = new JsonSerializer();
$xmlSerializer = new XmlSerializer();
$yamlSerializer = new YamlSerializer();
$testStudent = new TestObject('User 2', 30, [['php-basic', 'php-advance'],'python']);
echo "============[TestObject1]============" . PHP_EOL;
echo "----JSON:" . PHP_EOL;
echo $jsonSerializer->serialize($testStudent) . PHP_EOL;
echo "----YAML:" . PHP_EOL;
echo $yamlSerializer->serialize($testStudent) . PHP_EOL;
echo "----XML:" . PHP_EOL;
echo $xmlSerializer->serialize($testStudent) . PHP_EOL;