open-feature/cloudbees-provider

OpenFeature 的 CloudBees 提供程序包


README

a Latest Stable Version Total Downloads PHP 8.0+ License

概览

CloudBees 特性管理旨在大规模发布、控制和衡量特性。此存储库和包提供了通过 OpenFeature PHP SDK 与其交互的客户端代码。

此包还基于各种 PSR(PHP 标准建议)构建,例如日志接口(PSR-3)以及基本和扩展编码标准(PSR-1 和 PSR-12)。

局限性

在用于 Rollout、CloudBees PHP 特性管理 SDK 的上游库中存在一个未解决的问题,涉及对象反序列化。对象也不是特性管理系统的第一类公民,因为不存在直接检索“对象”的方式。相反,OpenFeature 提供程序基于字符串检索,JSON 作为预期格式。但由于上述未解决的问题,这并不真的有效。一旦解决这个问题,保存在 CloudBees 特性管理系统中的 JSON 对象将简单易访问。

安装

composer require open-feature/cloudbees-provider

用法

可以使用静态 setup 方法创建 CloudBeesProvider。这与 Rox::setup 方法非常相似,因此您可以参考 PHP 的 Rollout 文档此处获取更多信息。

// retrieve the OpenFeatureAPI instance
$api = OpenFeatureAPI::getInstance();

// setup the CloudBeesProvider with the default settings
$provider = CloudBeesProvider::setup($apiKey);

// set the OpenFeature provider
$api->setProvider($provider);

// retrieve an OpenFeatureClient
$client = $api->getClient('cloudbees-example', '1.0');

$flagValue = $client->getBooleanDetails('dev.openfeature.example_flag', true, null, null);

// ... do work with the $flagValue

// IMPORTANT! make sure to shutdown the CloudBees provider
CloudBeesProvider::shutdown();

开发

PHP 版本

此库针对 PHP 8.0 及更高版本。只要您的系统上安装了任何兼容版本的 PHP,您就应该能够利用 OpenFeature SDK。

此包还有一个 .tool-versions 文件,用于与 PHP 版本管理器(如 asdf)一起使用。

安装和依赖项

使用 composer install 安装依赖项。composer install 将更新 composer.lock,以包含最新的兼容版本。

我们重视尽可能少的使用时依赖项。添加任何依赖项都需要仔细考虑和审查。

测试

使用 composer run test 运行测试。

集成测试

集成测试套件利用一个本地的 Rollout 模拟服务器,称为 Roxy。

Docker 镜像在 rollout/roxy 下发布。

有关 Roxy 的更多信息,请参阅文档