defiant/randomorg
Composer 安装命令:
composer require defiant/randomorg
包简介
PHP class and Laravel implementation for Random.org
关键字:
README 文档
README
Native PHP and Laravel Implementation of Random.org's JSON-RPC API
Installation with Composer
composer require defiant/randomorg
or add it in your composer.json require block.
{
"require": {
"defiant/randomorg": "1.*"
}
}
and
composer update
Native PHP Usage
$apiKey = '00000000-0000-0000-0000-000000000000'; $random = new RandomOrg\Random($apiKey); // Simple method // following functions returns 52 random non-repeating numbers between 1-52 $result = $random->generateIntegers(52, 1, 52, false); // Signed methods // following functions returns the above with signed data $result = $random->generateIntegers(52, 1, 52, false, 10, true); // Verify Signature $verified = $random->verifySignature($result['result']['random'], $result['result']['signature']);
Laravel Usage
- Register service provider in your
config/app.phpfile.
RandomOrg\RandomServiceProvider::class
- Register the RandomOrg facade in the
aliaseskey of yourconfig/app.php
'RandomOrg' => RandomOrg\Facades\Random::class,
- Run a
vendor:publishartisan command to publish your configuration assets toconfig/randomorg.php
$ php artisan vendor:publish --provider="RandomOrg\RandomServiceProvider"
You may set your API key directly in your config/randomorg.php file or in your .env file like so:
RANDOM_ORG_API_KEY=00000000-0000-0000-0000-000000000000
Example code:
use RandomOrg; public function random() { return RandomOrg::generateIntegers(52, 1, 52, false); }
About API Keys
You can get your own API key at https://api.random.org/api-keys
Api Key (00000000-0000-0000-0000-000000000000) used in these examples will be disabled when the beta ends. Get your API key at https://api.random.org/api-keys
For the native implementation, there are three methods where you can set the API key in your class.
First in the constructor:
$apiKey = '00000000-0000-0000-0000-000000000000';
$random = new RandomOrg\Random($apiKey);
Secondly you can set it directly your class
protected $apiKey = '00000000-0000-0000-0000-000000000000';
or you can use the setApi method
$apiKey = '00000000-0000-0000-0000-000000000000';
$random = new RandomOrg\Random();
$random->setApiKey($apiKey);
Note: Method names are the same with simple method names on the API. To make signed request an optional boolean parameter is needed as the final argument.
Currently supports simple and signed methods below. For more information see https://api.random.org/json-rpc/1/
- generateIntegers
- generateDecimalFractions
- generateGaussians
- generateStrings
- generateUUIDs
- generateBlobs
- getUsage
- generateSignedIntegers
- generateSignedDecimalFractions
- generateSignedGaussians
- generateSignedStrings
- generateSignedUUIDs
- generateSignedBlobs
- verifySignature
defiant/randomorg 适用场景与选型建议
defiant/randomorg 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.48k 次下载、GitHub Stars 达 16, 最近一次更新时间为 2015 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「random」 「random.org」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 defiant/randomorg 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 defiant/randomorg 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 defiant/randomorg 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Faker Japanese is a Faker provider that generates fake Japanese related data for you.
Gambling Algorithms for Certification.
YAROC: Yet Another Random.Org Client.
Reusable utilities library for Lacus Solutions' packages (type description, HTML escaping, random sequences)
Random string generator
Laravel model support multi connection format master - slaves. Connect random a slave with weight
统计信息
- 总下载量: 2.48k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 16
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2015-06-08