gathern/growthbook-openfeature-provider
Composer 安装命令:
composer require gathern/growthbook-openfeature-provider
包简介
this package provide growthbook (a feature flag serice) provider to openfeature
README 文档
README
This is where your description should go. Try and limit it to a paragraph or two. Consider adding a small example.
Installation
You can install the package via composer:
composer require gathern/growthbook-openfeature-provider
Usage
<?php use Cache\Adapter\Apcu\ApcuCachePool; use Growthbook\Growthbook; use OpenFeature\OpenFeatureAPI; $growthbook Growthbook::create(); //By default, there is no caching enabled. // You can enable it by passing any PSR16-compatible // instance into the withCache method. // Any psr-16 library will work $cache = new ApcuCachePool(); $growthbook ->withCache($cache); $api = OpenFeatureAPI::getInstance(); $api->setProvider(new GrowthbookOpenfeatureProvider( growthbook: Growthbook, clientKey: '<Growthbook_CLIENT_KEY>', apiHost: '<Growthbook_API_HOST>', )); $client = $api->getClient( GrowthbookOpenfeatureProvider::class, 'v1.17', ); $client->getStringValue ( flagKey: 'enable-success-button', defaultValue: 'wrong', );
if you need to get the flag value of specific user attributes you can openfeature evaluation-context and set the user data as attributes .
<?php use OpenFeature\implementation\flags\Attributes; use OpenFeature\implementation\flags\MutableEvaluationContext; $user_data = [ 'name' => 'john Doe', 'age' => '20', 'gender' => 'male', 'nationality' => 'martian' ]; echo $client->getBooleanValue( flagKey: 'test-boolean', defaultValue: false, context: new MutableEvaluationContext( targetingKey: "targeting-key-value", attributes: new Attributes(attributesMap: $user_data) ) );
you can follow the usage of openfeature-php-package and docs of growthbook-php-sdk for instance of growthbook
if you need to use all growthbook sdk features or any feature service throw the openfeature api to reach feature using spatie/invade package just install it and follow this example
<?php $openfeatureAPI= invade($client)->api; $provider=invade($openfeatureAPI)->getProvider(); $growthbook=invade($provider)->growthbook; print_r($growthbook->getFeatures()); print_r($growthbook->getAttributes()); print_r( $growthbook->getViewedExperiments());
Testing
composer test:unit
Changelog
Please see CHANGELOG for more information on what has changed recently.
Credits
License
The MIT License (MIT). Please see License File for more information.
gathern/growthbook-openfeature-provider 适用场景与选型建议
gathern/growthbook-openfeature-provider 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 13.29k 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 04 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Gathern」 「growthbook-openfeature-provider」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 gathern/growthbook-openfeature-provider 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 gathern/growthbook-openfeature-provider 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 gathern/growthbook-openfeature-provider 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
统计信息
- 总下载量: 13.29k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 30
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-10