jeremykenedy/uuid
Composer 安装命令:
composer require jeremykenedy/uuid
包简介
Laravel package to generate a UUID according to the RFC 4122 standard. UUID Versions 1, 3, 4 and 5 are supported. With MIT license.
关键字:
README 文档
README
Laravel package to generate a UUID according to the RFC 4122 standard. UUID Versions 1, 3, 4 and 5 are supported. With MIT license.
- About
- Requirements
- Installation
- Basic Usage
- Advanced Usage
- Additional Features
- Changelog
- License
- Credits
About
Since Laravel 4.* and 5.* both rely on either OpenSSL or Mcrypt, the pseudo random byte generator now tries to use one of them. If both cannot be used (not a Laravel project?), the 'less random' mt_rand() function is used.
Requirements
Installation
Laravel 5.5 and above
- From your projects root folder in terminal run:
composer require jeremykenedy/uuid
- Uses package auto discovery feature, no need to edit the
config/app.phpfile.
Laravel 5.4 and below
- From your projects root folder in terminal run:
composer require jeremykenedy/uuid:2.1.2
- Register the package with laravel in
config/app.phpunderaliaseswith the following:
'aliases' => [ 'Uuid' => jeremykenedy\Uuid\Uuid::class, ];
Basic Usage
To quickly generate a UUID just do
Uuid::generate()
- This will generate a version 1 with a random ganerated MAC address.
Advanced Usage
UUID creation
UUID V1
Generate a version 1, time-based, UUID. You can set the optional node to the MAC address. If not supplied it will generate a random MAC address.
Uuid::generate(1,'00:11:22:33:44:55');
UUID V3
Generate a version 3, name-based using MD5 hashing, UUID
Uuid::generate(3,'test', Uuid::NS_DNS);
UUID V4
Generate a version 4, truly random, UUID
Uuid::generate(4);
UUID V5
Generate a version 5, name-based using SHA-1 hashing, UUID
Uuid::generate(5,'test', Uuid::NS_DNS);
Additional Features
Import UUID
- To import a UUID
$uuid = Uuid::import('d3d29d70-1d25-11e3-8591-034165a3a613');
Extract Time
- Extract the time for a time-based UUID (version 1)
$uuid = Uuid::generate(1); dd($uuid->time);
Extract Version
- Extract the version of an UUID
$uuid = Uuid::generate(4); dd($uuid->version);
Changelog
2.*
- Laravel Uuid is now fully PSR-2, just like Laravel 5.1.
- Not that much has changed except for UPPERCASING the constants used in Laravel Uuid.
- Meaning
Uuid::nsDNSis nowUuid::NS_DNSetc. Should be an easy fix.
Credits
- Full development credit must go to webpatser. This package was forked and modified to be compliant with MIT licensing standards for production use.
License
Laravel UUID is licensed under the MIT license for both personal and commercial products. Enjoy!
jeremykenedy/uuid 适用场景与选型建议
jeremykenedy/uuid 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 136.69k 次下载、GitHub Stars 达 23, 最近一次更新时间为 2017 年 07 月 19 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「UUID RFC4122」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 jeremykenedy/uuid 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jeremykenedy/uuid 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 jeremykenedy/uuid 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
DrUUID RFC 4122 library for PHP
Laravel package to generate and to validate a UUID according to the RFC 4122 standard. Only support for version 1, 3, 4 and 5 UUID are built-in. and generate number id, generate primary key
Trait to generate uuid when creating models
SilverStripe module for adding an unique id (UUID) to a DataObject
A CakePHP plugin for using secure, non-incremental IDs for entities
Add a factory management for Laramore
统计信息
- 总下载量: 136.69k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 23
- 点击次数: 28
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2017-07-19