keiko/uuid-shortener 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

keiko/uuid-shortener

最新稳定版本:v1.2.0

Composer 安装命令:

composer require keiko/uuid-shortener

包简介

A simple shortener library for RFC 4122 compatible UUIDs. Change your 36 chars long UUID into it's shorter equivalent.

README 文档

README

Minimum PHP Version Build Status

A simple shortener library for RFC 4122 compatible UUIDs. Change your 36 chars long UUID into it's shorter equivalent.

Key concept and inspiration taken from pascaldevink/shortuuid library. If you just need to generate short UUIDs the easy way, I encourage you to check his work. If you expect perfomance, this library uses ext-gmp to speed up the process.

Installation

The preferred method of installation is via Packagist and Composer. Run the following command to install the package and add it as a requirement to your project's composer.json:

composer require keiko/uuid-shortener

Example

<?php
require 'vendor/autoload.php';

use Keiko\Uuid\Shortener\Dictionary;
use Keiko\Uuid\Shortener\Shortener;

// Generate UUID, for example using Ramsey/UUID
$uuid = '806d0969-95b3-433b-976f-774611fdacbb';
$shortener = Shortener::make(
    Dictionary::createUnmistakable() // or pass your own characters set
);

echo $shortener->reduce($uuid); // output: mavTAjNm4NVztDwh4gdSrQ

You can reverse the process and expand your short UUID back to hexadecimal value.

<?php
require 'vendor/autoload.php';

use Keiko\Uuid\Shortener\Dictionary;
use Keiko\Uuid\Shortener\Shortener;

$shortUuid = 'mavTAjNm4NVztDwh4gdSrQ';
$shortener = Shortener::make(
    Dictionary::createUnmistakable()
);

echo $shortener->expand($shortUuid); // output: 806d0969-95b3-433b-976f-774611fdacbb 

Performance

In order to get optimal performance from this library, it is endorsed that you run ext-gmp in your system.

Keiko\Uuid\Shortener\Shortener::make() will pick a GMP-compatible shortener or a fallback shortener based on your system dependencies.

Plans

UUID Shortener is not connected with any UUID generator library. It also does not generate new UUIDs. It has only one purpose - transform your long, hexadecimal IDs (no matter where they come from), into a shorter and easier to read set of characters. In the near future additional service will be added, which will be able to generate short UUIDs in companion with most popular UUID generators.

统计信息

  • 总下载量: 205.55k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 150
  • 点击次数: 1
  • 依赖项目数: 2
  • 推荐数: 1

GitHub 信息

  • Stars: 150
  • Watchers: 3
  • Forks: 7
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-05-30