AG UUID

PHP UUID

How to generate a standard UUID (typically v4) in PHP, using the standard library or a widely used package.

Code

index.php
// composer require ramsey/uuid
use Ramsey\Uuid\Uuid;

$id = Uuid::uuid4()->toString();
Most languages provide v4 (random) out of the box, while v7 or ULID may require a separate library.

View version reference →