PHP code example of clsmedia / feature-flag

1. Go to this page and download the library: Download clsmedia/feature-flag 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/ */

    

clsmedia / feature-flag example snippets


use Clsmedia\FeatureFlag\FeatureFlag;

if (FeatureFlag::isActive('new_checkout')) {
    echo 'New checkout is enabled!';
}

setcookie('FEATURE_FLAGS', 'feature1,feature2', 0, '/');

// Check if a flag is active
FeatureFlag::isActive('feature1'); // true or false

// Check if a flag is missing (not active)
FeatureFlag::misses('feature1'); // true if not active

// Get all active flags
print_r(FeatureFlag::getFlags());

// Returns true if 'nonexistent' flag is not defined
FeatureFlag::isActive('nonexistent', true); // true

// Returns false if flag not defined (default)
FeatureFlag::isActive('nonexistent'); // false
env
FEATURE_FLAGS=summer_sale|2026-06-01T00:00:00;2026-08-31T23:59:59

FEATURE_FLAGS=flag1,flag2|2026-01-01T00:00:00;2026-12-31T23:59:59,flag3