PHP code example of decodelabs / guidance

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

    

decodelabs / guidance example snippets


use DecodeLabs\Guidance;
use DecodeLabs\Guidance\Uuid\Format;

// Generate a v4 UUID
$v4 = Guidance::createV4Uuid();
$version = $v4->version; // Version::V4

$string1 = (string)$v4; // Full UUID string
$string2 = $v4->shorten(); // Base 62 (default) encoded UUID
$string3 = $v4->shorten(Format::FlickrBase58); // Base 58 encoded UUID
echo $v4->bytes; // Raw bytes of the UUID

$new1 = Guidance::uuidFrom($string1); // Parse full UUID string
$new2 = Guidance::uuidFromShortString($string3, Format::FlickrBase58);

$ulid = Guidance::createUlid(); // Generate a ULID
echo $ulid->dateTime->format('Y-m-d H:i:s'); // Get the date and time from the ULID