PHP code example of aubes / openfeature-configcat-bundle

1. Go to this page and download the library: Download aubes/openfeature-configcat-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

aubes / openfeature-configcat-bundle example snippets


> Aubes\OpenFeatureConfigCatBundle\OpenFeatureConfigCatBundle::class => ['all' => true],
> 

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)) {
            // ...
        }
    }
}