Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 651 Bytes

use-other-uuid-versions.md

File metadata and controls

20 lines (15 loc) · 651 Bytes

Use other UUID versions

By default, this package uses the create_uuid function of the uuid extension which in returns creates UUIDs with version 4.

When you want other versions like for example 7 (that aren't even supported by the uuid extension), you can overwrite the generateRandom function of the Id class and create them through the ramsey/uuid or symfony/uid package.

use Symfony\Component\Uid\UuidV7;

final readonly class UserId extends Id
{
    #[\Override]
    public static function generateRandom(): UserId
    {
        $uuid7 = new UuidV7();
        
        return new static($uuid7->toRfc4122());
    }
}