1. Go to this page and download the library: Download systream/feature-switch 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/ */
systream / feature-switch example snippets
$feature = new Feature('foo_bar_feature_key');
$feature->isEnabled(); // will return: false
$feature = new Feature('foo_bar_feature_key');
$feature->addSwitcher(Simple::on());
$feature->isEnabled(); // will return: true
$feature = new Feature('foo_bar_feature_key');
$feature->addSwitcher(new AB());
$feature->isEnabled();
$feature = new Feature('foo_bar_feature_key');
$feature->addSwitcher(new Until(\DateTime::createFromFormat('Y-m-d H:i:s', '2017-08-12 10:00:00')));
$feature->isEnabled(); // brefore 2017-08-12 10:00:00 it's return false, after will return true
$feature = new Feature('foo_bar_feature_key');
$feature->addSwitcher(new Until(\DateTime::createFromFormat('Y-m-d H:i:s', '2017-08-12 10:00:00'), false));
$feature->isEnabled(); // brefore 2017-08-12 10:00:00 it's return true, after will return false
$feature = new Feature('foo_bar_feature_key');
$feature->addSwitcher(
new Callback(function() {
/* do custom logic */
return true;
})
);
$feature->isEnabled();