承接 pragmarx/random 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

pragmarx/random

Composer 安装命令:

composer require pragmarx/random

包简介

Create random chars, numbers, strings

README 文档

README

Latest Stable Version Software License Build Status Code Coverage Scrutinizer Code Quality StyleCI

Generate random strings, numbers, bytes, patterns, and a lot more

Features

It generates cryptographically secure pseudo-random bytes (using random_bytes() and random_int()) to make:

  • Strings
  • Numbers (strings or integers)
  • Upper, lower and mixed case
  • Prefixed and suffixed random strings
  • Hexadecimal
  • Regex patterns ([abcd], [aeiou], [A-Z0123], [0-9a-f])
  • Raw strings, giving you whatever random_bytes() generates

Faker

If you have Faker installed it falls back to it, giving you access to random names, dates, cities, phones, and a lot more.

Install

Via Composer

$ composer require pragmarx/random

Usage

Basic array usage

$this->random = new PragmaRX\Random\Random();

$this->random->get(); /// will generate an alpha string which is the same of

$this->random->alpha()->get();

Should give you 16 chars (default size) string

   Ajv3ejknLmqwC36z

Defining the size

$this->random->size(32)->get();

Upper and lower case

$this->random->uppercase()->get();
$this->random->lowercase()->size(255)->get();

To get back to mixed case you can just:

$this->random->mixedcase()->get();

Defining a pattern

The pattern method uses regex, so you can:

$this->random->pattern('[abcd]')->get();

$this->random->pattern('[A-F0-9]')->get(); /// Hexadecimal

To get

   abcddcbabbacbbdabbcb

Numeric and Integer

The pattern method uses regex, so you can:

$this->random->numeric()->start(10)->end(20)->get();

To get

   (int) 18

But if you set the size

$this->random->numeric()->size(3)->get();

You'll get a string

   (string) 123

Hexadecimal

$this->random->hex()->size(10)->get();

Hexadecimal is uppercase by default, but you can get a lowercase by doing:

$this->random->hex()->lowercase()->get();

Prefix && Suffix

$this->random->hex()->prefix('#')->size(6)->lowercase()->get();

And you should get a random CSS color:

#fafafa

Of course, the same works for suffixes

$this->random->prefix('!')->suffix('@')->get();

Trivia

There are currently 43982 questions in the trivia database, and this is how you get them:

$this->random->trivia()->get();

$this->random->trivia()->count(2)->get();

You'll need to install the Trivia database package:

$ composer require pragmarx/trivia

Faker

If you install Faker

composer require fzaninotto/faker

You'll also have access to all of the Faker features, like:

$this->random->city()->get();

And also use all other features of Random

$this->random->prefix('city: ')->city()->lowercase()->get();

You can also change the faker class, you another one pleases you more:

$this->random->fakerClass(AnotherFaker\Factory::class)->date()->get();

Raw strings

Usually the package returns characters in the range of Base64 (A to Z, a to z and 0 to 9), but you can completely disable this feature and make it return whatever random_bytes() generates:

$this->random->raw()->get();

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer update
$ vendor/bin/phpunit

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email acr@antoniocarlosribeiro.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.

pragmarx/random 适用场景与选型建议

pragmarx/random 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4.54M 次下载、GitHub Stars 达 71, 最近一次更新时间为 2017 年 09 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「faker」 「random」 「random string」 「pragmarx」 「Randomize」 「random number」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 pragmarx/random 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 pragmarx/random 我们能提供哪些服务?
定制开发 / 二次开发

基于 pragmarx/random 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 71
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2017-09-18