Skip to content

Other Identifiers

Mint supports several additional identifier types for specialized use cases. Each provides unique characteristics suited to different scenarios.

Collision-Resistant Unique Identifier - The successor to CUID, designed for security and horizontal scalability.

PropertyValue
Length24 characters (default)
SortableNo (secure randomness)
CharactersLowercase alphanumeric
Collision resistantYes
use Cline\Mint\Mint;
// Generate with default length (24)
$cuid2 = Mint::cuid2()->generate();
echo $cuid2->toString(); // "ckn4l3dw10000vl1d8b0n8b1c"
// Custom length (10-32)
$cuid2 = Mint::cuid2()->length(32)->generate();
  • Security-sensitive identifiers
  • Systems requiring unpredictable IDs
  • Horizontal scaling scenarios

Globally Unique Sortable ID - A 96-bit identifier inspired by MongoDB ObjectID but with a simpler structure.

PropertyValue
Length20 characters
Size96 bits (12 bytes)
SortableYes
EncodingBase32 (Crockford)
ComponentBitsDescription
Timestamp32Unix seconds
Machine ID24Machine identifier
Process ID16Process identifier
Counter24Incrementing counter
// Generate
$xid = Mint::xid()->generate();
echo $xid->toString(); // "9m4e2mr0ui3e8a215n4g"
// Parse
$xid = Mint::xid()->parse('9m4e2mr0ui3e8a215n4g');
$timestamp = $xid->getTimestamp();
// Validate
Mint::xid()->isValid($input);
  • Cross-platform distributed systems
  • When you need smaller IDs than UUID (12 vs 16 bytes)
  • Go-compatible systems (XID is popular in Go)

MongoDB-Style Identifier - 96-bit identifiers used natively by MongoDB.

PropertyValue
Length24 characters (hex)
Size96 bits (12 bytes)
SortableYes
EncodingHexadecimal
ComponentBytesDescription
Timestamp4Unix seconds
Machine3Machine identifier
Process2Process ID
Counter3Incrementing counter
// Generate
$objectId = Mint::objectId()->generate();
echo $objectId->toString(); // "507f1f77bcf86cd799439011"
// Parse
$objectId = Mint::objectId()->parse('507f1f77bcf86cd799439011');
$timestamp = $objectId->getTimestamp();
// Validate
Mint::objectId()->isValid($input);
  • MongoDB integrations
  • Systems that need MongoDB-compatible IDs
  • Migrating from/to MongoDB

Firebase-Style Identifier - Chronologically sortable identifiers designed for Firebase Realtime Database.

PropertyValue
Length20 characters
SortableYes (chronological)
CharactersURL-safe Base64
ComponentCharactersDescription
Timestamp8Milliseconds
Randomness12Random entropy
// Generate
$pushId = Mint::pushId()->generate();
echo $pushId->toString(); // "-L7v3WZPJz_H5QfA5jDE"
// Parse
$pushId = Mint::pushId()->parse('-L7v3WZPJz_H5QfA5jDE');
$timestamp = $pushId->getTimestamp();
// Validate
Mint::pushId()->isValid($input);
  • Firebase Realtime Database integration
  • Real-time applications needing chronological ordering
  • Systems requiring millisecond-precision timestamps

128-bit Time-Sortable Identifier - Combines Unix timestamp with random data for sortable, collision-resistant IDs.

PropertyValue
Length26 characters
Size128 bits
SortableYes
EncodingBase62
ComponentBitsDescription
Timestamp48Milliseconds since epoch
Random80Cryptographic randomness
// Generate
$timeflake = Mint::timeflake()->generate();
echo $timeflake->toString(); // "01FH8W5A1Z2Y3X4W5V6U7T8S9R"
// Parse
$timeflake = Mint::timeflake()->parse('01FH8W5A1Z2Y3X4W5V6U7T8S9R');
$timestamp = $timeflake->getTimestamp();
// Validate
Mint::timeflake()->isValid($input);
  • Database primary keys requiring chronological sorting
  • Alternative to ULID with Base62 encoding
  • Systems needing timestamp + randomness

TypeLengthSortableTimestampUse Case
CUID224NoNoSecurity-focused random IDs
XID20YesSecondsGo-compatible, compact
ObjectID24YesSecondsMongoDB compatibility
PushID20YesMillisecondsFirebase, real-time apps
Timeflake26YesMillisecondsGeneral purpose, Base62
use Cline\Mint\Mint;
// CUID2 - Secure random
$cuid2 = Mint::cuid2()->generate(); // "ckn4l3dw10000..."
$cuid2 = Mint::cuid2()->length(32)->generate(); // Longer variant
// XID - Compact sortable
$xid = Mint::xid()->generate(); // "9m4e2mr0ui3e8a215n4g"
$xid = Mint::xid()->parse($string);
// ObjectID - MongoDB style
$objectId = Mint::objectId()->generate(); // "507f1f77bcf86cd799439011"
$objectId = Mint::objectId()->parse($string);
// PushID - Firebase style
$pushId = Mint::pushId()->generate(); // "-L7v3WZPJz_H5QfA5jDE"
$pushId = Mint::pushId()->parse($string);
// Timeflake - Time-sortable
$timeflake = Mint::timeflake()->generate(); // "01FH8W5A1Z2Y3X4W5V6U7T8S9R"
$timeflake = Mint::timeflake()->parse($string);

All conductors support:

MethodDescription
generate()Generate a new identifier
parse(string $value)Parse an identifier string
isValid(string $value)Validate format

All identifier objects support:

MethodReturnsDescription
toString()stringString representation
getBytes()stringBinary representation
getTimestamp()?intUnix milliseconds (if sortable)
isSortable()boolWhether time-ordered
MethodDescription
length(int $length)Set output length (10-32)