mini\uuid7() Function

Documentation

Generate a UUID v7 (time-ordered + cryptographically random).

UUID v7 combines Unix timestamp (milliseconds) with cryptographic randomness, providing natural chronological ordering and better database index performance.

Example Usage

$id = uuid7();  // "018c8f3a-2b4e-7a1c-9f23-4d5e6f7a8b9c"

Common Use Cases

  • Database primary keys (better B-tree performance)
  • Sortable identifiers
  • Time-range queries
  • High-volume write operations

Note: This is the same as uuid() by default, but calling uuid7() explicitly ensures you get v7 even if the default factory is customized.

Signature

function uuid7(): string

Returns

string

Source

src/UUID/functions.php:91-93