Doctrine object types mapping support

0.5.0 2020-06-04 16:45 UTC

This package is auto-updated.

Last update: 2022-01-04 20:28:48 UTC


Latest Version Software License PHP Version Total Downloads

Maps immutable object and object list to single json field.


Make sure Composer is installed globally, as explained in the installation chapter of the Composer documentation.

Applications that don't use Symfony

Step 1: Download library

$ composer require sbooker/doctrine-object-mapping 

Step 2: Create and register Doctrine type

class Concrete { /* ... */ }

class ConcreteType extends \Sbooker\DoctrineObjectMapping\ObjectType 
    protected function getObjectClass(): string
        return Concrete::class;

    public function getName()
        return 'concrete';

\Doctrine\DBAL\Types\Type::addType('concrete', ConcreteType::class);

// Create or get normalizer
$normalizer = new \Symfony\Component\Serializer\Normalizer\ObjectNormalizer(/*...*/);

// Set serializer to type on boot application
/** @var \Sbooker\DoctrineObjectMapping\NormalizableType $type */
$type = \Doctrine\DBAL\Types\Type::getType('concrete');

Applications that use Symfony

Use sbooker/doctrine-object-mapping-bundle


See LICENSE file.