1. Go to this page and download the library: Download jadb/feature_toggle 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/ */
jadb / feature_toggle example snippets
use FeatureToggle\FeatureRegistry;
use Predis\Client as Redis;
FeatureRegistry::setStorage(new Redis());
FeatureRegistry::init('Cool Feature', [
'description' => 'A cool new feature!',
'strategies' => [
'UserAgent' => [['/opera/', '/Mozilla\/5\.0/']],
function ($Feature) {
return !empty($_SESSION['isAdmin']);
},
function ($Feature) {
return !empty($_SESSION[$Feature->getName()]);
}
]
]);
FeatureRegistry::init('Another Cool Feature', [
'type' => 'threshold', // use the `ThresholdFeature`
'description' => 'Another cool new feature!',
'strategies' => [
'UserAgent' => [['/opera/', '/Mozilla\/5\.0/']],
function ($Feature) {
return !empty($_SESSION['isAdmin']);
},
function ($Feature) {
return !empty($_SESSION[$Feature->getName()]);
}
]
])->threshold(2); // Require at least 2 strategies to pass
if (\FeatureToggle\FeatureManager::isEnabled('Cool Feature')) {
// do something
}
$ php composer.phar install
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.