PHP code example of kissous / uuid7
1. Go to this page and download the library: Download kissous/uuid7 library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
kissous / uuid7 example snippets
use Kissous\Uuid7\Uuid7;
// Generate a new UUIDv7
$uuid = Uuid7::generate();
echo $uuid->toString(); // e.g. 0190f3a4-7b2c-7def-8123-456789abcdef
echo $uuid; // same output (Stringable)
// Parse an existing string (case-insensitive, normalized to lowercase)
$parsed = Uuid7::fromString('0190F3A4-7B2C-7DEF-8123-456789ABCDEF');
// Validation: throws InvalidUuidException if the string is not a valid UUIDv7
use Kissous\Uuid7\Exception\InvalidUuidException;
try {
Uuid7::fromString('not-a-uuid');
} catch (InvalidUuidException $e) {
// ...
}