PHP code example of domainflow / uuid

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

    

domainflow / uuid example snippets


use DomainFlow\Uuid\{UuidV1, UuidV2, UuidV3, UuidV4, UuidV5, UuidV6, UuidV7, UuidV8};

UuidV1::generate();                     // Time-based UUID (v1)
UuidV2::generate(1001, 'uid');          // DCE Security UUID (v2)
UuidV3::generate($ns, 'my-name');       // Name-based UUID with MD5 (v3)
UuidV4::generate();                     // Random UUID (v4)
UuidV5::generate($ns, 'my-name');       // Name-based UUID with SHA-1 (v5)
UuidV6::generate();                     // Time-ordered UUID (v6)
UuidV7::generate();                     // Unix timestamp UUID (v7)
UuidV8::generate();                     // Application-defined/custom UUID (v8)

use DomainFlow\Uuid\Inspector;

$inspector = Inspector::analyze('your-uuid-here');
$inspector->version();   // int (e.g. 4)
$inspector->variant();   // string (e.g. "RFC 4122")
$inspector->metadata();  // array with version-specific data

UuidV3::generate(string $namespace, string $name);
UuidV5::generate(string $namespace, string $name);