PHP code example of ada-u / chocoflake

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

    

ada-u / chocoflake example snippets


$config = new IdConfig(41, 5, 5, 12, 1414334507356);
$service = new ChocoflakeService($config);

$worker = $service->createIdWorkerOnSharedMemory(new RegionId(1), new ServerId(1));

$id = $worker->generate();
4194439168
bash
$ docker-compose run php vendor/bin/phpunit
Creating chocoflake_php_run ... done
PHPUnit 9.5.6 by Sebastian Bergmann and contributors.

....                                                                4 / 4 (100%)

Time: 00:00.353, Memory: 6.00 MB

OK (4 tests, 4 assertions)