Skip to content

Doctrine Database Abstraction Layer

An overview of available infrastructural code when using Doctrine's Database Abstraction Layer.

Domain Identifier Type

A translation between the database type and an identifier type in PHP is provided by MsgPhp\Domain\Infrastructure\Doctrine\DomainIdType.

Basic Example

<?php

use Doctrine\DBAL\Types\Type;
use MsgPhp\Domain\Infrastructure\Doctrine\DomainIdType;

// --- SETUP ---

class MyDomainIdType extends DomainIdType
{
    public const NAME = 'my_domain_id';
}

// --- USAGE ---

MyDomainIdType::setClass(MyDomainId::class);
MyDomainIdType::setDataType(Type::GUID);

Type::addType(MyDomainIdType::NAME, MyDomainIdType::class);

To leverage a tailored UUID identifier use one of the UUID data types provided by ramsey/uuid-doctrine.

<?php

use Ramsey\Uuid\Doctrine\UuidType;

MyDomainIdType::setClass(MyDomainUuid::class);
MyDomainIdType::setDataType(UuidType::NAME);