macx/rfc-4122-uuid
Composer 安装命令:
composer require macx/rfc-4122-uuid
包简介
PHP-Class to generate valid RFC 4122 compliant Universally Unique IDentifiers (UUID) version 3, 4 and 5.
关键字:
README 文档
README
The following class generates VALID RFC 4122 COMPLIANT Universally Unique IDentifiers (UUID) version 3, 4 and 5.
UUIDs generated validates using OSSP UUID Tool, and output for named-based UUIDs are exactly the same. This is a pure PHP implementation.
Author: Andrew Moore posted this as a note at the PHP Manual back in 2010.
Install
If you're using Composer as a package manager for PHP, put this require directive in your composer.json and run composer install in your CLI.
{
"require" : {
"macx/rfc-4122-uuid" : "1.0.*"
}
}
Or require it via command line with:
$ composer require macx/rfc-4122-uuid 1.0.*
Generate a unique ID
To generate a ID simply copy the following code:
include 'vendor/autoload.php'; $uuid = macx\UUID::v4(); echo 'The generated UUID is `' . $uuid . '`';
If you want to validate a ID against RFC do this:
$givenId = 'f81d4fae-7dec-11d0-a765-00a0c91e6bf6'; if(macx\UUID::is_valid($givenId)) { // do something }
统计信息
- 总下载量: 7.5k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2014-10-14