PHP code example of coosos / jms-serializer-bidirectional-relation
1. Go to this page and download the library: Download coosos/jms-serializer-bidirectional-relation 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/ */
coosos / jms-serializer-bidirectional-relation example snippets
use JMS\Serializer\SerializerBuilder;
use JMS\Serializer\EventDispatcher\EventDispatcher;
use Coosos\BidirectionalRelation\EventSubscriber\MapDeserializerSubscriber;
use Coosos\BidirectionalRelation\EventSubscriber\MapSerializerSubscriber;
$builder = SerializerBuilder::create();
$builder->configureListeners(function (EventDispatcher $dispatcher) {
$dispatcher->addSubscriber(new MapSerializerSubscriber());
$dispatcher->addSubscriber(new MapDeserializerSubscriber());
});
$serializer = $builder->build();