iliain/php-zoo-ids
Composer 安装命令:
composer require iliain/php-zoo-ids
包简介
A PHP version of bryanmylee's zoo-ids, originally written in JavaScript
关键字:
README 文档
README
A PHP version of bryanmylee's zoo-ids, originally written in JavaScript, which was in turn inspired by the URL ID's of gfycat.com. For a frontend or backend that uses JavaScript, I highly recommend you use their package!
Generate predictable and unique identifiers composed of adjectives and animal names, with the ability to seed the random identifiers.
Range of IDs
Currently, there are 1347 adjectives and 221 animals. The more adjectives used, the more possible combinations of IDs available.
For a quick reference, with 2 adjectives used, there are 400,984,389 possible unique IDs.
With 3 adjectives, there are 540,125,971,983 possible unique IDs.
Installation
$ composer require iliain/php-zoo-ids
Usage
Examples
use Iliain\ZooIDs\UsernameRandomizer; $randomizer = new UsernameRandomizer(); $randomizer->generateID('short seed'); // KnobbyNauticalKingfisher // Defaults to the current time if seed is null. $randomizer->generateID(null, 2, '🍓', 'lowercase'); // enchanted🍓narrow🍓wallaby
If you want to control the list of Nouns and Adjectives, you can provide your own:
$randomizer = new UsernameRandomizer(['Jumping','Flying','Running','Waving'], ['Rock', 'Paper', 'Scissors']); $randomizer->generateID(); // JumpingRunningScissors $randomizer->setAdjectives(['Diving','Walking','Spinning']); $randomizer->generateID(); // WalkingDivingScissors $randomizer->setNouns(['Koala', 'Dog']); $randomizer->generateID(); // WalkingDivingKoala
Documentation
new UsernameRandomizer($adjectives, $nouns)
adjectives: array
An array of adjectives to use in generation. Defaults to preprovided list if none are specified.
nouns: array
An array of nouns to use in generation. Defaults to preprovided list if none are specified.
generateID($seed, $numAdjectives, $delimiter, $caseStyle)
seed: string|int
The seed used to generate the id. This allows us to generate predictable, but random and unique identifiers.
Defaults to the current time.
numAdjectives: int
The number of adjectives to use in the identifier.
Defaults to 2.
delimiter: string
The delimiter used between words. The delimiter will also be used between multi-word adjectives.
Defaults to ''.
caseStyle: string
The case style for the words. Possible options are 'titlecase', 'camelcase', 'uppercase', 'lowercase', and 'togglecase'.
generateID($seed, $numAdjectives, $delimiter, 'titlecase'); // FineAntiqueElk generateID($seed, $numAdjectives, $delimiter, 'camelcase'); // pertinentPoshGoldfinch generateID($seed, $numAdjectives, $delimiter, 'uppercase'); // PIERCINGRESPONSIBLECAMEL generateID($seed, $numAdjectives, $delimiter, 'lowercase'); // imaginarywingedsalamander generateID($seed, $numAdjectives, $delimiter, 'togglecase'); // sTuNnInGdEsCrIpTiVepEaFoWl
Defaults to 'titlecase'.
Credits
All credit goes to Bryan Lee and his zoo-ids package. I wanted a version of this to use in PHP (username generation was handled by a PHP CMS), and converted the majority of his existing code to that format. Currently lacking some of his original features, such as the ability to use objects as seeds.
iliain/php-zoo-ids 适用场景与选型建议
iliain/php-zoo-ids 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 11 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「random」 「usernames」 「zoo-ids」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 iliain/php-zoo-ids 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 iliain/php-zoo-ids 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 iliain/php-zoo-ids 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Faker Japanese is a Faker provider that generates fake Japanese related data for you.
Gambling Algorithms for Certification.
Reusable utilities library for Lacus Solutions' packages (type description, HTML escaping, random sequences)
Random string generator
A list of dangerous usernames
Laravel model support multi connection format master - slaves. Connect random a slave with weight
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2022-11-21