getjoystick/joystick-php
Composer 安装命令:
composer require getjoystick/joystick-php
包简介
Joystick is a modern remote configuration and dynamic content service designed specifically for operating apps and games. Upgrade to more agility and evolve your product faster. Change or hot-update your content and configurations instantly at scale without code. Segment, ab test, feature flag, sche
关键字:
README 文档
README
This is the library that simplifies the way how you can communicate with Joystick API.
Requirements
PHP 7.2 and later
Installation
You can install the package via Composer:
composer require getjoystick/joystick-php
We will try to find the PSR-18 compatible HTTP client within your dependencies using
php-http/discovery, if you don't have one
installed, just run this command to install
Guzzle HTTP client:
composer require guzzlehttp/guzzle
Usage
To use the client, use Composer's autoload:
require_once 'vendor/autoload.php';
Simple usage looks like this:
$config = \Joystick\ClientConfig::create()->setApiKey(getenv('JOYSTICK_API_KEY')); $client = \Joystick\Client::create($config); $getContentsResponse = $client->getContents(['content-id1', 'content-id2']); $getContentsResponse->myProperty1 $getContentsResponse->myProperty2
Requesting Content by single Content Id
$getContentResponse = $client->getContent('content-id1'); $getContentResponse->myProperty1
Specifying additional parameters:
When creating the ClientConfig object, you can specify additional parameters which will be used
by all API calls from the client, for more details see
API documentation:
$config = \Joystick\ClientConfig::create() ->setApiKey(getenv('JOYSTICK_API_KEY')) ->setCacheExpirationSeconds(600) // 10 mins ->setSerialized(true) ->setParams([ 'param1' => 'value1', 'param2' => 'value2', ]) ->setSemVer('0.0.1') ->setUserId('user-id-1');
Options
fullResponse
In most of the cases you will be not interested in the full response from the API, but if you're you can specify
fullResponse option to the client methods. The client will return you raw API response:
$getContentResponse = $client->getContent('content-id1', ['fullResponse' => true]); // OR $getContentsResponse = $client->getContents(['content-id1', 'content-id2'], ['fullResponse' => true]);
serialized
When true, we will pass query parameter responseType=serialized
to Joystick API.
$getContentResponse = $client->getContent('content-id1', ['serialized' => true]); // OR $getContentsResponse = $client->getContents(['content-id1', 'content-id2'], ['serialized' => true]);
refresh
If you want to ignore existing cache and request the new config – pass this option as true.
$getContentResponse = $client->getContent('content-id1', ['refresh' => true]); // OR $getContentsResponse = $client->getContents(['content-id1', 'content-id2'], ['refresh' => true]);
This option can be set for every API call from the client by setting setSerialized(true):
$config = \Joystick\ClientConfig::create() ->setApiKey(getenv('JOYSTICK_API_KEY')) ->setSerialized(true)
Caching
By default, the client uses array caching, which means that if you build the HTTP application where each process exits after the request has been processed – the cache will be erased after the process is finished.
You can specify your cache implementation which conforms PSR-16.
See examples/file-cache for more details.
Clear the cache
If you want to clear the cache – run $client->clearCache().
Note that we will call
clear()on the PSR-16 interface. Make sure that you use different cache instances in different places of your app
HTTP Client
If you want to provide custom HTTP client, which may be useful for use-cases like specifying custom proxy, collecting detailed metrics about HTTP requests,
You can specify your HTTP client implementation which conforms PSR-18.
See examples/custom-http-client for more details.
Testing
To run unit tests, just run:
phpunit
Security
If you discover any security related issues, please email letsgo@getjoystick.com instead of using the issue tracker.
Credits
License
The MIT. Please see License File for more information.
getjoystick/joystick-php 适用场景与选型建议
getjoystick/joystick-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.16k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2023 年 03 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「AB Testing」 「segmentation」 「feature flagging」 「remote configuration」 「dynamic content」 「remote configs」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 getjoystick/joystick-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 getjoystick/joystick-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 getjoystick/joystick-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Simple text sentence splitting and counting. Supports at least english, german and dutch, possibly more.
A block that displays featured content - large image, title, description and link.
Testing Suite For Lumen like Laravel does.
MaxAl Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
The PHP SDK for Checkmango
Rinvex Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
统计信息
- 总下载量: 1.16k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 26
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-03