Generate ULID using PHP

robinvdvleuten/ulid library

  1. Add robinvdvleuten/ulid library to composer.json file:
"require": {
    "robinvdvleuten/ulid": "^5.0"
}
  1. Install library from the command line:
composer install
  1. Generate ULID:
<?php

require_once __DIR__.'/vendor/autoload.php';

use Ulid\Ulid;

$ulidStr = (string) Ulid::generate();
echo $ulidStr;

Leave a Comment

Cancel reply

Your email address will not be published.