1. Go to this page and download the library: Download itav/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/ */
itav / serializer example snippets
use Itav\Component\Serializer\Serializer;
private $model = 'SomeModel';
private $color = 'red';
/**
* @var Part[]
*/
private $parts;
public function setParts($parts)
{
$this->parts = $parts;
}
}
class Part
{
private $number = 123;
private $name = 'engine';
}
$car = new Car();
$car->setParts([new Part(), new Part(), new Part()]);
$array = $serializer->normalize($car);
$json = json_encode($array);