定制 defiant/randomorg 二次开发

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

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

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.php file.
RandomOrg\RandomServiceProvider::class
  • Register the RandomOrg facade in the aliases key of your config/app.php
'RandomOrg' => RandomOrg\Facades\Random::class,
  • Run a vendor:publish artisan command to publish your configuration assets to config/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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 16
  • Watchers: 3
  • Forks: 8
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2015-06-08