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.
| Property | Value |
|---|
| Length | 24 characters (default) |
| Sortable | No (secure randomness) |
| Characters | Lowercase alphanumeric |
| Collision resistant | Yes |
// Generate with default length (24)
$cuid2 = Mint::cuid2()->generate();
echo $cuid2->toString(); // "ckn4l3dw10000vl1d8b0n8b1c"
$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.
| Property | Value |
|---|
| Length | 20 characters |
| Size | 96 bits (12 bytes) |
| Sortable | Yes |
| Encoding | Base32 (Crockford) |
| Component | Bits | Description |
|---|
| Timestamp | 32 | Unix seconds |
| Machine ID | 24 | Machine identifier |
| Process ID | 16 | Process identifier |
| Counter | 24 | Incrementing counter |
$xid = Mint::xid()->generate();
echo $xid->toString(); // "9m4e2mr0ui3e8a215n4g"
$xid = Mint::xid()->parse('9m4e2mr0ui3e8a215n4g');
$timestamp = $xid->getTimestamp();
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.
| Property | Value |
|---|
| Length | 24 characters (hex) |
| Size | 96 bits (12 bytes) |
| Sortable | Yes |
| Encoding | Hexadecimal |
| Component | Bytes | Description |
|---|
| Timestamp | 4 | Unix seconds |
| Machine | 3 | Machine identifier |
| Process | 2 | Process ID |
| Counter | 3 | Incrementing counter |
$objectId = Mint::objectId()->generate();
echo $objectId->toString(); // "507f1f77bcf86cd799439011"
$objectId = Mint::objectId()->parse('507f1f77bcf86cd799439011');
$timestamp = $objectId->getTimestamp();
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.
| Property | Value |
|---|
| Length | 20 characters |
| Sortable | Yes (chronological) |
| Characters | URL-safe Base64 |
| Component | Characters | Description |
|---|
| Timestamp | 8 | Milliseconds |
| Randomness | 12 | Random entropy |
$pushId = Mint::pushId()->generate();
echo $pushId->toString(); // "-L7v3WZPJz_H5QfA5jDE"
$pushId = Mint::pushId()->parse('-L7v3WZPJz_H5QfA5jDE');
$timestamp = $pushId->getTimestamp();
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.
| Property | Value |
|---|
| Length | 26 characters |
| Size | 128 bits |
| Sortable | Yes |
| Encoding | Base62 |
| Component | Bits | Description |
|---|
| Timestamp | 48 | Milliseconds since epoch |
| Random | 80 | Cryptographic randomness |
$timeflake = Mint::timeflake()->generate();
echo $timeflake->toString(); // "01FH8W5A1Z2Y3X4W5V6U7T8S9R"
$timeflake = Mint::timeflake()->parse('01FH8W5A1Z2Y3X4W5V6U7T8S9R');
$timestamp = $timeflake->getTimestamp();
Mint::timeflake()->isValid($input);
- Database primary keys requiring chronological sorting
- Alternative to ULID with Base62 encoding
- Systems needing timestamp + randomness
| Type | Length | Sortable | Timestamp | Use Case |
|---|
| CUID2 | 24 | No | No | Security-focused random IDs |
| XID | 20 | Yes | Seconds | Go-compatible, compact |
| ObjectID | 24 | Yes | Seconds | MongoDB compatibility |
| PushID | 20 | Yes | Milliseconds | Firebase, real-time apps |
| Timeflake | 26 | Yes | Milliseconds | General purpose, Base62 |
$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:
| Method | Description |
|---|
generate() | Generate a new identifier |
parse(string $value) | Parse an identifier string |
isValid(string $value) | Validate format |
All identifier objects support:
| Method | Returns | Description |
|---|
toString() | string | String representation |
getBytes() | string | Binary representation |
getTimestamp() | ?int | Unix milliseconds (if sortable) |
isSortable() | bool | Whether time-ordered |
| Method | Description |
|---|
length(int $length) | Set output length (10-32) |