Skip to content

Universally Unique Identifier

An overview of available infrastructural code when working with UUIDs.

Domain Identifier

A UUID tailored domain identifier trait is provided by MsgPhp\Domain\Infrastructure\Uuid\DomainIdTrait.

Basic Example

<?php

use MsgPhp\Domain\DomainId;
use MsgPhp\Domain\Infrastructure\Uuid\DomainIdTrait;
use Ramsey\Uuid\Uuid;

// --- SETUP ---

class MyDomainUuid implements DomainId
{
    use DomainIdTrait;
}

$id = new MyDomainUuid(); // a new UUID version 4 value
$id = new MyDomainUuid(Uuid::uuid1());
$id = new MyDomainUuid(Uuid::fromString('00000000-0000-0000-0000-000000000000'));