定制 switchover/php-sdk 二次开发

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

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

switchover/php-sdk

Composer 安装命令:

composer require switchover/php-sdk

包简介

Switchover PHP SDK. Feature Toggle Management made easy!

README 文档

README

CI codecov CodeFactor

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 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 307
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 4
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-18