PHP code example of real-digital / half-flake
1. Go to this page and download the library: Download real-digital/half-flake 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/ */
real-digital / half-flake example snippets
use Real\HalfFlake;
// an unique pair of constants defined per node
const ID_DATACENTER = 1;
const ID_NODE = 1;
$shard = new HalfFlake\Seed(ID_DATACENTER, ID_NODE);
$clock = new HalfFlake\Time();
try {
$generator = new HalfFlake\Generator($shard, $clock);
$id = $generator->nextId();
} catch (HalfFlake\RuntimeException $e) {
// handle errors
}