davispeixoto / featuretoggle
A PHP Feature Toggle library
Installs: 16 695
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 2
Open Issues: 0
Requires
- php: >=5.4.0
- hassankhan/config: *
Requires (Dev)
- phpunit/phpunit: ~4.0
README
This package provides a simple feature toggle mechanism for PHP applications.
Installation
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 update
Configuration
Just 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 ], ... ];
Usage
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 }
License
This software is licensed under the MIT license
Versioning
This project follows the Semantic Versioning
Thanks
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.