2017 © Pedro Peláez
 

library feature-toggle

Feature toggle library

image

treehouselabs/feature-toggle

Feature toggle library

  • Wednesday, February 21, 2018
  • by fieg
  • Repository
  • 7 Watchers
  • 0 Stars
  • 431 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 6 Versions
  • 5 % Grown

The README.md

Feature Toggle

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score, (*1)

Simple feature toggle library, (*2)

Installation

composer require treehouselabs/feature-toggle

Usage

$features = new FeatureToggleCollection();
$features->registerToggle(
    'feature-x',
    new BooleanFeatureToggle(true)
);

if ($features->isEnabled('feature-x')) {
    // perform stuff for feature-x
}

Behat context

# behat.yml

default:
  suites:
    default:
        contexts:
          - TreeHouse\FeatureToggle\Bridge\Behat\FeatureToggleContext:
              cacheItemPool: '@cache_item_pool' #PSR-6 cache item pool
<?php
   class Feature
   {
       private $features;

       public function __construct(FeatureToggleCollectionInterface $features) {
           $this->features = $features;
       }

       public function indexAction()
       {
           if ($this->features->isEnabled('feature-y')) {
               return 'Enabled!';
           }

           return 'Disabled!';
       }
   }

   $toggleCollection = new CacheFeatureToggleCollection();
   $toggleCollection->setCacheItemPool($psr6CacheItemPool);

   // Overwrite the FeatureToggleCollection with the CacheFeatureToggleCollection in test env
   new Feature($toggleCollection);
# feature-y.feature

Feature: Feature-Y

  Scenario: Feature-Y is enabled
    Given the feature toggle "feature-y" is enabled
    And I am on the homepage
    Then I should see "Enabled!"

  Scenario: Feature-Y is disabled
#   Given the feature toggle "feature-y" is disabled (default)
    Given I am on the homepage
    Then I should see "Disabled!"

Testing

bash composer test, (*3)

Security

If you discover any security related issues, please email dev@treehouse.nl instead of using the issue tracker., (*4)

License

The MIT License (MIT). Please see License File for more information., (*5)

Credits

The Versions

21/02 2018
21/02 2018
22/03 2017
21/03 2017
16/01 2017