PHP code example of tsantos / serializer
1. Go to this page and download the library: Download tsantos/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/ */
tsantos / serializer example snippets
use TSantos\Serializer\SerializerBuilder;
class Post {
public $title;
public $summary;
}
$serializer = (new SerializerBuilder())
->setHydratorDir('/path/to/generated/hydrators')
->build();
$person = new Post('Post title', 'Post summary');
echo $serializer->serialize($person); // {"title":"Post title", "summary":"Post summary"}