aubes/openfeature-configcat-bundle

Symfony bundle for the OpenFeature ConfigCat provider

Maintainers

Package info

github.com/aubes/openfeature-configcat-bundle

Type:symfony-bundle

pkg:composer/aubes/openfeature-configcat-bundle

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.0 2026-04-14 00:02 UTC

This package is auto-updated.

Last update: 2026-04-14 00:05:21 UTC


README

CI Latest Version PHP Version Symfony Version

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-client for HTTP requests)

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

This bundle registers ConfigCatProvider as a lazy Symfony service. You can inject it directly:

use ConfigCat\OpenFeature\ConfigCatProvider;
use OpenFeature\API;

class MyService
{
    public function __construct(private ConfigCatProvider $provider)
    {
    }

    public function doSomething(): void
    {
        $client = API::getInstance()
            ->withProvider($this->provider)
            ->getClient();

        if ($client->getBooleanValue('dark_mode', false)) {
            // ...
        }
    }
}

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.