Download the PHP package infocyph/uid without Composer
On this page you can find all versions of the php package infocyph/uid. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package uid
UID
An AIO Unique ID generator written in PHP. Supports (references available at the bottom),
- UUID
- ULID
- Snowflake ID
- Sonyflake ID
- TBSL
- NanoId
- Cuid2
Table of contents
- Prerequisites
- Installation
- Usage
- UUID
- UUID v1
- UUID v3
- UUID v4
- UUID v5
- UUID v6
- UUID v7
- UUID v8
- GUID
- Additional
- ULID
- Snowflake ID
- Sonyflake ID
- TBSL ID
- RandomId
- NanoId
- Cuid2
- UUID
- Benchmark
- Support
- References
Prerequisites
Language: PHP 8/+
Installation
Usage
UUID (Universal Unique Identifier)
The node specific UUID's $node
parameter (1, 6, 7, 8) is optional. If not provided, it will be generated randomly.
But, if you wanna track the source of the UUIDs, you should use it (pre-define the node per server & pass it
accordingly).
UUID v1: Time-based UUID.
-
Generate v1 UUID
- Pass your pre-generated node (for node specific UUID)
UUID v3: Namespace based UUID.
-
Generate v3 UUID
-
Get v3 UUID for predefined namespaces (RFC4122 #Appendix C)
- You can generate a UUID & use as namespace as well
UUID v4: Random UUID.
- Generate v4 UUID
UUID v5: Namespace based UUID.
-
Generate v5 UUID
-
Get v5 UUID for predefined namespaces (RFC4122 #Appendix C)
- You can generate a UUID & use as namespace as well
UUID v6 (draft-based/unofficial): Time-based UUID.
-
Generate v6 UUID
- Get v6 UUID using predefined node:
UUID v7 (draft-based/unofficial): Time-based UUID.
-
Generate v7 UUID
-
Get v7 UUID using predefined node:
-
Or if you wanna get v7 UUID using predefined time:
- You can combine both parameters together as well.
UUID v8 (draft-based/unofficial): Time-based UUID. Lexicographically sortable.
-
Generate v8 UUID
- Get v8 UUID using predefined node:
GUID
GUID generator, works in all platform. Generate:
Note: Sending false in only parameter will return the string enclosed with Braces
Additional
-
Generate node for further use (with version: 1, 6, 7, 8)
- Parse any UUID string:
ULID (Universally Unique Lexicographically Sortable Identifier)
-
Generating ULID is very simple,
-
Or if you wanna get ULID for specific time:
-
Extract datetime from any ULID string:
- Validate any ULID string:
Snowflake ID
-
Generate a new Snowflake ID (You can also pass your pre-generated worker_id & datacenter_id for server/module detection):
-
Parse Snowflake ID (get the timestamp, sequence, worker_id, datacenter_id):
- Specify start time for Snowflake ID (a Snowflake ID is unique upto 69 years from the start date):
Sonyflake ID
-
Generate a new Sonyflake ID (You can also pass your pre-generated machine_id for server detection):
-
Parse Sonyflake ID (get the timestamp, sequence, machine_id):
- Specify start time for Sonyflake ID (a Sonyflake ID is unique upto 174 years from the start date):
TBSL: Time-Based Keys with Lexicographic Sorting (library exclusive)
-
Get TBSL ID (You can also pass your pre-generated machine_id for server detection):
- Parse TBSL ID (get the timestamp, machine_id):
RandomId
With this you can generate RandomIds. These are great for usage where you don't want a large length/formatted IDs like UUID4. These IDs are unique & can't be backtracked.
NanoID (URL friendly Unique Random ID)
- Generate
Cuid2 (URL friendly, secure & collision free)
- Generate
Benchmark
Type | Generation time (ms) |
---|---|
UUID v1 (random node) | 0.00411 (ramsey/Uuid: 0.18753) |
UUID v1 (fixed node) | 0.00115 (ramsey/Uuid: 0.17386) |
UUID v3 (custom namespace) | 0.00257 (ramsey/Uuid: 0.03015) |
UUID v4 | 0.00362 (ramsey/Uuid: 0.16501) |
UUID v5 (custom namespace) | 0.00108 (ramsey/Uuid: 0.03658) |
UUID v6 (random node) | 0.00444 (ramsey/Uuid: 0.17469) |
UUID v6 (fixed node) | 0.00164 (ramsey/Uuid: 0.17382) |
UUID v7 (random node) | 0.00503 (ramsey/Uuid: 0.16278) |
UUID v7 (fixed node) | 0.00154 (ramsey/Uuid: 0.18753) |
UUID v8 (random node) | 0.00505 (ramsey/Uuid: N/A) |
UUID v8 (fixed node) | 0.00209 (ramsey/Uuid: 0.16029 *predefined random node, not usable as signature) |
ULID | 0.00506 (robinvdvleuten/php-ulid: 0.00508) |
Snowflake | 0.13951 (godruoyi/php-snowflake: 0.14856) |
Sonyflake | 0.13821 (godruoyi/php-snowflake: 0.14583) |
TBSL | 0.0034 |
NanoID | 0.00057 |
Cuid2 | 0.01817 |
Support
Having trouble? Create an issue!
References
- UUID (RFC4122): https://tools.ietf.org/html/rfc4122
- UUID (Drafts/Proposals): https://datatracker.ietf.org/doc/draft-ietf-uuidrev-rfc4122bis
- ULID: https://github.com/ulid/spec
- Snowflake ID: https://github.com/twitter-archive/snowflake/tree/snowflake-2010
- Sonyflake ID: https://github.com/sony/sonyflake
- TBSL ID: https://github.com/infocyph/UID/blob/main/TBSL.md
- NanoID: https://github.com/ai/nanoid
- Cuid2: https://github.com/paralleldrive/cuid2
All versions of uid with dependencies
ext-bcmath Version *