PHP code example of pyyoshi / shortuuid-php

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

    

pyyoshi / shortuuid-php example snippets



\ShortUUID\Autoloader::register();

use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->uuid();
=> "rkQdp5ikpXjraCsrSaysaT"

use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->uuid('example.com');
=> "wpsWLdLt9nscn2jbTD3uxe"
$su->uuid('http://www.example.com/');
=> "VSPugLzk4dD4WC7yfAQUzn"

use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->getAlphabet();
=> "23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"

use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->setAlphabet('aaaaabcdefgh1230123');
$su->uuid();
=> "ee120aeh2h3bb010fdfedef2c03efcf3h1ca"

use ShortUUID\ShortUUID;

$su = new ShortUUID();
$su->setAlphabet('aaaaabcdefgh1230123');
$su->getAlphabet();
=> "0123abcdefgh"

use Ramsey\Uuid\Uuid;
use ShortUUID\ShortUUID;

$u = Uuid::uuid4();
$su = new ShortUUID();
$s = $su->encode($u);

$su->decode($s) == $u;
=> true
bash
composer 
json
{
    "yyoshi/shortuuid-php": "*"
    }
}