1. Go to this page and download the library: Download marcinjean/minisnowflake 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/ */
marcinjean / minisnowflake example snippets
use MarcinJean\MiniSnowflake\MiniSnowflake;
// Generate a new ID
$id = MiniSnowflake::generateId();
echo $id; // Example: "00D2D87XE"
// Validate an ID
if (MiniSnowflake::isValidId($id)) {
echo "ID is valid!";
}
// Decode an ID
$data = MiniSnowflake::decodeId($id);
print_r($data);
/*
Array
(
[timestamp] => 1714256780000
[datetime] => 2025-04-27 22:19:40
[sequence] => 123
)
*/
// Set a custom epoch (in milliseconds)
MiniSnowflake::setEpoch(strtotime('2024-01-01 00:00:00') * 1000);
// Reset to default epoch (2025-01-01)
MiniSnowflake::resetEpoch();