PHP code example of hshn / serializer-extra-bundle

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

    

hshn / serializer-extra-bundle example snippets


/** @var $serializer JMS\Serializer\Serializer */
$json = $serializer->serialize($blog, 'json');

class Blog
{
}

class User
{
    /**
     * @var Blog
     */
    private $blog;
}

$serializer->serialize($blog, 'json'); // will export the blog authorities (depth 0)
$serializer->serialize($user, 'json'); // will NOT export the blog authorities (depth 1)

/** @var $serializer JMS\Serializer\Serializer */
$json = $serializer->serialize($blog, 'json');