This package provides a simple feature toggle mechanism for PHP applications.
The package can be installed via Composer by requiring the
davispeixoto/featuretoggle package in your project's composer.json.
{
"require": {
"davispeixoto/featuretoggle": "~1.0"
}
}And running a composer update from your terminal:
php composer.phar updateJust put your features into the config file, with their respective state (true or false):
return [
'my_feature' => true,
'my_other_feature' => [
'pt_br' => true,
'en_us' => true,
'es_es' => false
],
...
];That's it! You're all set to go. Just use:
Davispeixoto\FeatureToggler\FeatureToggler;
...
$toggler = new FeatureToggler('path/to/my_config_file.php');
if($toggler->isEnabled('my_feature')) {
// do the feature here
}
...
// for multidimensional config array
if($toggler->isEnabled('my_other_feature.en_us')) {
// new code here
} else {
// old code here
}This software is licensed under the MIT license
This project follows the Semantic Versioning
An amazing "Thank you, guys!" for Jetbrains folks, who kindly empower this project with a free open-source license for PhpStorm which can bring a whole new level of joy for coding.




