open-feature / cloudbees-provider
OpenFeature 的 CloudBees 提供程序包
Requires
- php: ^8
- open-feature/sdk: ^2.0
- rollout/rox: ^5.0
Requires (Dev)
- ergebnis/composer-normalize: ^2.25
- friendsofphp/php-cs-fixer: ^3.13
- hamcrest/hamcrest-php: ^2.0
- mdwheele/zalgo: ^0.3.1
- mockery/mockery: ^1.5
- phan/phan: ^5.4
- php-parallel-lint/php-console-highlighter: ^1.0
- php-parallel-lint/php-parallel-lint: ^1.3
- phpstan/extension-installer: ^1.1
- phpstan/phpstan: ~1.10.0
- phpstan/phpstan-mockery: ^1.0
- phpstan/phpstan-phpunit: ^1.1
- psalm/plugin-mockery: ^0.11.0
- psalm/plugin-phpunit: ^0.18.0
- ramsey/coding-standard: ^2.0.3
- ramsey/composer-repl: ^1.4
- ramsey/conventional-commits: ^1.3
- roave/security-advisories: dev-latest
- spatie/phpunit-snapshot-assertions: ^4.2
- vimeo/psalm: ~4.30.0
README
概览
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 的更多信息,请参阅文档。