定制 cxj/uuid 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

cxj/uuid

最新稳定版本:v1.0.1

Composer 安装命令:

composer require cxj/uuid

包简介

A PHP UUID implementation

关键字:

README 文档

README

Provides a native PHP implementation of UUID creation.

This class supports version 4 (random) and version 5 (SHA-1) UUID generation algorithms. It generates the DCE 1.1 variant UUID, the most common outside of Microsoft environments.

The UUIDs generated are RFC 4122 compliant.

Introduction

Installation

This class only requires PHP 4 or later, but we recommend using the latest available version of PHP as a matter of principle. It has no dependencies.

It is installable and autoloadable via Composer as [cxj/uuid] (https://packagist.org/packages/cxj/uuid).

Alternatively, [download a release] (https://github.com/cxj/uuid/releases) or clone this repository, then require or include its autoload.php file.

Quality

This class attempts to comply with PSR-1, PSR-2, and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Design Goals

This class was designed to cover only the most common use cases, and to be small and lightweight. Hence, there are some features it does not provide.

In particular:

  • It does not provide a version 1 (MAC address) implementation, because there is no reliable and lightweight method to obtain the MAC address from PHP. There are also criticisms of version 1 which make it less desirable.

  • Version 2 (DCE Security) is also not presently implemented. The need for this version appears small.

  • It does not provide a version 3 (MD5) implementation. MD5 has been shown to have weaknesses, and version 5 (SHA-1) is recommended for usage instead.

  • It is a UUID generator, so very little UUID parsing and validation is part of the code at present.

Usage

The UUID generation methods are static, so simply call them as shown below.

<?php

$namespace_uuid = '1546058f-5a25-4334-85ae-e68f2a44bbaf';

// Some meaningful string, e.g. fully-qualified domain name, URL, distinguished
// name, or any other textual name.
$name = 'http://example.com/';

$v4uuid = UUID::v4();
$v5uuid = UUID::v5($v4uuid, $name);
$v5uuid2 = UUID::v5($namespace_uuid, $name);


echo "v4: $v4uuid" .PHP_EOL;
echo "v5: $v5uuid" .PHP_EOL;
echo "v5: $v5uuid2" .PHP_EOL;

?>

Contributing

Pull requests are welcome!

Requests which follow the PSR-1 and PSR-2 coding and style standards, and which have PHPUnit test coverage will get most attention.

统计信息

  • 总下载量: 27
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: BSD-2-Clause
  • 更新时间: 2015-05-30