V4 UUID generator class.
More...
◆ generate()
static core\uuid::generate |
( |
| ) |
|
|
static |
Generate a V4 UUID.
Unique is hard. Very hard. Attempt to use the PECL UUID function if available, and if not then revert to constructing the uuid using random_bytes or mt_rand.
It is important that this token is not solely based on time as this could lead to duplicates in a clustered environment (especially on VMs due to poor time precision).
UUIDs are just 128 bits long but with different supported versions (RFC 4122), mainly two:
- V1: the goal is uniqueness, at the cost of anonymity since it is coupled to the host generating it, via its MAC address.
- V4: the goal is randomness, at the cost of (rare) collisions. Here, the V4 type is the preferred choice.
The format is: xxxxxxxx-xxxx-4xxx-Yxxx-xxxxxxxxxxxx where x is any hexadecimal digit and Y is a random choice from 8, 9, a, or b.
- See also
- https://tools.ietf.org/html/rfc4122
- Return values
-
◆ generate_uuid_via_pecl_uuid_extension()
static core\uuid::generate_uuid_via_pecl_uuid_extension |
( |
| ) |
|
|
staticprotected |
◆ generate_uuid_via_random_bytes()
static core\uuid::generate_uuid_via_random_bytes |
( |
| ) |
|
|
staticprotected |
The documentation for this class was generated from the following file: