Skip to content

Latest commit

 

History

History
25 lines (17 loc) · 979 Bytes

doctrine.md

File metadata and controls

25 lines (17 loc) · 979 Bytes

Serialize Doctrine ORM Entities

Library use neomerx/json-api package for encode data to json:api structures.

Doctrine wrap your own class to Proxy, this issues explained in neomerx/json-api#40.

Library provide solution for it. Example of dependency injection (free-elephants/di container configuration):

# index.php 
use FreeElephants\DI\InjectorBuilder;
use FreeElephants\JsonApiToolkit\Neomerx\Encoder;
use Neomerx\JsonApi\Contracts\Encoder\EncoderInterface;

$components = require_once 'components.php'; 
$container = (new InjectorBuilder())->buildFromArray($components);

Encoder::setPsrContainer($container);
$schemas = require_once 'jsonapi-schemas.php'; // your json:api schemas map for neomerx encoder
$jsonApiEncoder = Encoder::instance($schemas);

$container->setService(EncoderInterface::class, $jsonApiEncoder);

// other application code