PHP code example of wickedbyte / int-to-uuid

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

    

wickedbyte / int-to-uuid example snippets


$id = \WickedByte\IntToUuid\IntegerId::make(42);
$uuid = \WickedByte\IntToUuid\IntToUuid::encode($id);
echo $uuid->toString(); // 99c45a05-a33b-8544-8024-f4be69401069

$id = \WickedByte\IntToUuid\IntegerId::make(42, 12);
$uuid = \WickedByte\IntToUuid\IntToUuid::encode($id);
echo $uuid->toString(); // dee5e9d2-c3e4-8273-b0d5-b3b5307bf749

$uuid = \Ramsey\Uuid\Uuid::fromString('99c45a05-a33b-8544-8024-f4be69401069');
$id = \WickedByte\IntToUuid\IntToUuid::decode($uuid);
echo $id->value; // 42
echo $id->namespace; // 0

$uuid = \Ramsey\Uuid\Uuid::fromString('dee5e9d2-c3e4-8273-b0d5-b3b5307bf749');
$id = \WickedByte\IntToUuid\IntToUuid::decode($uuid);
echo $id->value; // 42
echo $id->namespace; // 12