PHP code example of ndtan / id-generator
1. Go to this page and download the library: Download ndtan/id-generator 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/ */
ndtan / id-generator example snippets
use ndtan\Manager;
use ndtan\Uuid\UuidV7Generator;
use ndtan\Ulid\UlidGenerator;
use ndtan\Snowflake\SnowflakeGenerator;
$mgr = new Manager([
'default' => 'uuid7',
'drivers' => [
'uuid7' => [ 'class' => UuidV7Generator::class ],
'ulid' => [ 'class' => UlidGenerator::class, 'monotonic' => true ],
'snowflake' => [ 'class' => SnowflakeGenerator::class, 'epoch' => '2020-01-01T00:00:00Z' ],
]
]);
echo $mgr->generate(); // UUIDv7
echo $mgr->driver('ulid')->generate(); // ULID