davispeixoto/featuretoggle

A PHP Feature Toggle library

1.0.4 2016-08-11 17:59 UTC

This package is auto-updated.

Last update: 2024-10-24 04:50:44 UTC


README

This package provides a simple feature toggle mechanism for PHP applications.

Latest Stable Version Total Downloads Scrutinizer Code Quality Code Coverage Build Status SensioLabsInsight

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.

Jetbrains

PhpStorm