PHP code example of jp3cki / uuid

1. Go to this page and download the library: Download jp3cki/uuid 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/ */

    

jp3cki / uuid example snippets




declare(strict_types=1);

use jp3cki\uuid\Uuid;

 171f5526-f910-11ed-88b6-ea8c2b49d6b3
echo Uuid::v1('08:00:2b:01:02:03') . "\n"; // outputs: 171f6804-f910-11ed-bae3-08002b010203

// Sortable version of UUIDv1
echo Uuid::v6() . "\n";                    // outputs: 1edf9101-71f6-69a8-9474-0ea6f6ebdfa1
echo Uuid::v6('08:00:2b:01:02:03') . "\n"; // outputs: 1edf9101-71f6-6a7a-a7fb-08002b010203

// Sortable and no host information
echo Uuid::v7() . "\n";                    // outputs: 01884666-7e1c-7cc2-a6e0-34adc6d76b52



declare(strict_types=1);

use jp3cki\uuid\Uuid;

-ba00-5e59b15895a0



declare(strict_types=1);

use jp3cki\uuid\Uuid;
use jp3cki\uuid\NS as UuidNS;

 5df41881-3aed-3515-88a7-2f4a814cf09e

// version 5, SHA-1
echo Uuid::v5(UuidNS::dns(), 'www.example.com') . "\n"; // output: 2ed6657d-e927-568b-95e1-2665a8aea6a2



declare(strict_types=1);

use jp3cki\uuid\Uuid;
use jp3cki\uuid\NS as UuidNS;

-870a-873f-ed73f2bc5b2c




declare(strict_types=1);

use jp3cki\uuid\Uuid;

usted to match UUIDv8.
echo Uuid::v8(str_repeat(chr(0x00), 16)) . "\n"; // output: 00000000-0000-8000-8000-000000000000

// You can also give a random number sequence, but you should use UUIDv4.
echo Uuid::v8(random_bytes(16)) . "\n";          // output: bfc47fb7-948f-8833-87e0-cae07c85d30d
echo Uuid::v4() . "\n";




declare(strict_types=1);

use jp3cki\uuid\Ulid;