switchover/php-sdk
Composer 安装命令:
composer require switchover/php-sdk
包简介
Switchover PHP SDK. Feature Toggle Management made easy!
关键字:
README 文档
README
Switchover
Switchover is a Software-As-A-Service for managing feature toggles (aka switches, flags or feature flips) in your application. Use it for Continous Integration, Continous Delivery, A/B-Testing, Canary Releases, Experementing and everything else you can think of.
Note: Use this SDK for PHP Projects
Getting Started
Install
Via composer:
composer require switchover/php-sdk
For Laravel Users
Use our Laravel Package to get up and running quickly with Switchover in your Laravel App: https://github.com/switchover-io/laravel-integration
Initialize client
You will find your SDK Key on the environment page. Copy it and use it to initialize the client:
Basic usage:
// create a client, per default the client will cache the toggles 60 seconds $client = new SwitchoverClient('<SDK-KEY'); //get some toggle values $featureValue = $client->toggleValue('<TOGGLE-NAME>', false); //or with context if you have specific (user) conditions $context = new Context(); $context->set('email', 'brandon.taylor@acme.com'); $isFeatureVisible = $client->toggleValue('<OTHER-FLAG>', false, $context); if ($isFeatureVisible) { // ...do something }
What is the Context?
The context holds any data (key-value pair) which should be evaluated against the toggle conditions. This can be anything, from user-related data (email, userId) to pure technical infos (stage, system infos, versions, etc). If you have rollout options you have to provide a uuid (more details below).
👀 PLEASE NOTE We do not send any context data (and such any user data) to our servers. All evaluations happens on the client.
In an user webfrontend you would typically want to use userdata like email or userId, etc. to evaluate you feature flag. Of course the toggle conditions should also contain the relevant context key.
Example:
$ctx = new Context([ "email" => "brandon.taylor@bigcorp.org" ]); $isFeatureEnabled = $client->toggleValue('my-big-feature', false, $ctx);
If you have specified a rollout option for you feature flag it is important to provide a UUID. You can freely choose, but should be unique.
Example:
/* Feature flag has rollout options so we must provide a uuid. Here we use the email */ $ctx = new Context([ "uuid" => "brandon.taylor@bigcorp.org" ]);
⚠️ IMPORTANT: Rollout options expects a uuid. Toggle evaluation will fail and return the default value if you don't provide the uuid.
Client Options
It's possible to pass numerous options to the client:
| Option | Value |
|---|---|
cache.time |
Sets time in seconds before the internal cache becomes stale and will be refreshed (TTL). Default is 60 seconds. The value 0 will keep the cache forever. |
logger |
Possibility to provide you own logger instance (PSR-7). |
cache |
Option to set your cache instance (e.g. for redis). Expects a PSR-16 compliant instance. |
http |
The client uses guzzlehttp/guzzle for http requests. You can pass an array of options to the Guzzle Http Client. |
Example
$client = new SwitchoverClient('<SDK-KEY', [ 'cache.time' => 10, 'http' => [ 'timeout' => '10', 'proxy' => 'http://proxy.tld' ] ]);
Documentation
Learn more on the official documentation: Switchover Quickstart
switchover/php-sdk 适用场景与选型建议
switchover/php-sdk 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 307 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 11 月 18 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「laravel」 「feature flag」 「feature switch」 「feature toggle」 「switchover」 「switch-over」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 switchover/php-sdk 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 switchover/php-sdk 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 switchover/php-sdk 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A block that displays featured content - large image, title, description and link.
Cold template caches that can be flagged and automatically invalidated.
Laravel Eloquent boolean & timestamp flagged attributes behavior.
Bitwise flag setting for Yii 2.x
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.
Country Flag Emoji for PHP
统计信息
- 总下载量: 307
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-11-18