aubes/openfeature-configcat-bundle
最新稳定版本:v0.1.0
Composer 安装命令:
composer require aubes/openfeature-configcat-bundle
包简介
Symfony bundle for the OpenFeature ConfigCat provider
README 文档
README
Symfony bundle that registers the OpenFeature ConfigCat provider as a Symfony service.
ConfigCat in Symfony, one composer require away.
Requirements
- PHP 8.2+
- Symfony 6.4, 7.4 or 8.x
- Guzzle ^7.0 (required by
configcat/configcat-clientfor HTTP requests; see "Using without Guzzle" below to switch)
Installation
composer require aubes/openfeature-configcat-bundle
Note: Without a Symfony Flex recipe, register the bundle manually in
config/bundles.php:Aubes\OpenFeatureConfigCatBundle\OpenFeatureConfigCatBundle::class => ['all' => true],
Configuration
# config/packages/open_feature_configcat.yaml open_feature_config_cat: sdk_key: '%env(CONFIGCAT_SDK_KEY)%' # Optional settings base_url: ~ # custom ConfigCat CDN URL cache_refresh_interval: ~ # polling interval in seconds data_governance: ~ # "global" or "eu_only" offline: ~ # start in offline mode # Optional service references (Symfony service IDs) logger: ~ # PSR-3 LoggerInterface cache: ~ # ConfigCat\ConfigCache implementation (mutually exclusive with cache_pool) cache_pool: ~ # PSR-6 CacheItemPoolInterface, e.g. "cache.app" (mutually exclusive with cache) fetch_client: ~ # ConfigCat\Http\FetchClientInterface implementation # Flag overrides (optional, pick one type) flag_overrides: type: file # "file", "array", or "service" behaviour: local_only # "local_only", "local_over_remote", or "remote_over_local" path: ~ # JSON file path (type: file) # values: ~ # inline key/value map (type: array) # id: ~ # service ID of OverrideDataSource (type: service)
Usage
Inject the provider directly
This bundle registers ConfigCatProvider as a Symfony service. You can inject it directly and use the OpenFeature API:
use ConfigCat\OpenFeature\ConfigCatProvider; use OpenFeature\OpenFeatureAPI; class MyService { public function __construct(private ConfigCatProvider $provider) { } public function doSomething(): void { $client = OpenFeatureAPI::getInstance() ->setProvider($this->provider) ->getClient(); if ($client->getBooleanValue('dark_mode', false)) { // ... } } }
Pair with aubes/openfeature-bundle (optional)
If you want framework-level sugar on top of the OpenFeature SDK (#[FeatureFlag] / #[FeatureGate] attributes, Twig helpers, request-scoped evaluation context, profiler integration), install aubes/openfeature-bundle alongside and point it at this provider:
# config/packages/open_feature.yaml open_feature: provider: ConfigCat\OpenFeature\ConfigCatProvider
It's entirely optional: this bundle works fine on its own with the plain OpenFeature SDK.
Using without Guzzle
By default, ConfigCat uses Guzzle for HTTP requests. If you prefer symfony/http-client (or any PSR-18 client), this bundle ships a Psr18FetchClient adapter:
# config/services.yaml services: Aubes\OpenFeatureConfigCatBundle\Http\Psr18FetchClient: arguments: $client: '@psr18.http_client' $requestFactory: '@Psr\Http\Message\RequestFactoryInterface' # config/packages/open_feature_configcat.yaml open_feature_config_cat: sdk_key: '%env(CONFIGCAT_SDK_KEY)%' fetch_client: Aubes\OpenFeatureConfigCatBundle\Http\Psr18FetchClient
This requires symfony/http-client and a PSR-17 implementation (e.g. nyholm/psr7).
License
MIT. See LICENSE.
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-04-14