fwolf/uuid

Time Based UUID Generator

v1.1 2016-10-13 16:14 UTC

This package is auto-updated.

Last update: 2024-12-10 03:56:15 UTC


README

Travis Latest Stable Version License SensioLabsInsight Scrutinizer Code Quality

Generate time based UUID, with custom format and length.

UUIDs follow alphabetical order, more suitable for database primary key.

Short UUID save more space, and little more eye candy.

Check digit can determine if an UUID is valid, maybe useful.

Install

composer require fwolf/uuid:~1.1

UUID Types

By inherit these classes and modify constant value, you can:

  • Define length of each part
  • Enable check digit
  • Change of enable/disable separator between parts

Usage

use Fwolf\Util\Uuid\Base36;

$generator = new Base36();

$uuid = $generator->generate();
echo "Generated UUID: {$uuid}";
// Result: Generated UUID: 1bjzaogobg01b0tjd6q2qx6t9

There are some utility scripts in bin directory:

  • explain.php Disassemble UUID to parts and generated time
  • find-offset-base36.php Find latest offset timestamp for Base36
  • find-offset-base62Short.php Find latest offset timestamp for Base36Short

License

Distribute under MIT License.