nishadil/uuid
最新稳定版本:v1.2.0
Composer 安装命令:
composer require nishadil/uuid
包简介
A PHP library for generating universally unique identifiers (UUID).
README 文档
README
A PHP library for generating universally unique identifiers (UUID).
What is a UUID?
A UUID (short for Universally Unique IDentifier) is a 36-character alphanumeric string that can be used to identify information. For example, they are commonly used to identify rows of data in database tables, with each row assigned a specific UUID.
Here is an example of a UUID: acde070d-8c4c-4f0d-9d8a-162843c10333
One reason UUIDs are so widely used is that they are likely to be globally unique. In other words, not only row UUIDs are unique within a row. A database table is probably the only row with that UUID on any system.
(Technically it's not impossible that the same UUID you generate could be used elsewhere, but it's highly unlikely as there are 340,282,366,920,938,463,463,374,607,431,768,211,456 possible different UUIDs.)
UUIDs version status
| Versions | Status | Info |
|---|---|---|
| v1 | working |
UUIDs using date-time and MAC address |
| v2 | working |
UUIDs using date-time and MAC address, DCE security version. |
| v3 | working |
UUIDs based on the MD5 hash of some data. |
| v4 | working |
UUIDs with random data. |
| v5 | working |
UUIDs based on the SHA1 hash of some data. |
| v6 | working |
UUIDs using a timestamp and monotonic counter. |
| v7 | working |
UUIDs using a Unix timestamp. |
| v8 | working |
UUIDs using user-defined data. |
Installation
This library can be installed using [Composer][]. To install, please use following command
composer require nishadil/uuid
How to use
Autoload the library once:
<?php require __DIR__.'/vendor/autoload.php'; use Nishadil\Uuid\Uuid;
v1 (time-based):
$uuidV1 = Uuid::v1()->get();
v2 (DCE security, UID/GID domain):
$uuidV2 = Uuid::v2() ->withLocalDomain('uid') // or 'gid' ->withLocalId(1000) ->get();
v3 (name-based, MD5):
$uuidV3 = Uuid::v3() ->withNamespace('6ba7b810-9dad-11d1-80b4-00c04fd430c8') ->withName('www.example.com') ->get();
v4 (random):
$uuidV4 = Uuid::v4()->get();
v5 (name-based, SHA1):
$uuidV5 = Uuid::v5() ->withNamespace('6ba7b810-9dad-11d1-80b4-00c04fd430c8') ->withName('www.example.com') ->get();
v6 (reordered time-based):
$uuidV6 = Uuid::v6()->get();
v7 (Unix time, ms):
$uuidV7 = Uuid::v7()->get();
v8 (custom data, 16 bytes / 32 hex chars):
$uuidV8 = Uuid::v8() ->withCustomHex('00112233445566778899aabbccddeeff') ->get();
License
This library is licensed for use under the MIT License (MIT)
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-07-10