2017 © Pedro Peláez
 

library feature

image

feature/feature

  • Friday, February 14, 2014
  • by rmasters
  • Repository
  • 1 Watchers
  • 2 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

feature/feature Build status Coverage Status

A simple feature-flag API that can be used for toggling functionality., (*1)

Usage

$features = new FeatureManager;

$features->setUser(new User(['id' => 1]));

$features->enable('new_calendar', function(Feature\User $user) {
    return in_array($user->id, [1, 2, 5]);
});

if ($features->can('new_calendar')) {
    // ...
}

Enable features by adding toggles that inspect attributes of the current user. Toggles can be as simple as a closure or any instance that implements Toggle., (*2)

Storage

Feature toggles can be defined in three ways:, (*3)

  • Direct PHP - as above,
  • a structured array,
  • or from a database.

Closures are supported by PHP and arrays in PHP (i.e. not from YAML etc.) Files and database require the toggle definitions to be pre-defined., (*4)

Structured array

$featureToggles = [
    // Feature name
    'view_calendar' => [
        // Each toggle with it's class name and constructor arguments
        ['name' => 'Feature\Toggles\IPWhitelist', 'params' => ['127.0.0.1']],

        // or a closure
        function(Feature\User $user) {
            return $user->id % 3 == 0;
        },

        // or a Toggle instance
        new Feature\Toggles\IPWhitelist(['192.168.0.1', '192.168.0.2']),
    ]
];

$features = new FeatureManager;
$storage = new Feature\Storage\Structured($features, $featureToggles);
$storage->load();

The Versions

14/02 2014

dev-master

9999999-dev

  Sources   Download

MIT

The Development Requires

feature toggle flag

12/02 2014

dev-laravel4

dev-laravel4

  Sources   Download

MIT

The Development Requires

feature toggle flag

12/02 2014

v0.2.0

0.2.0.0

  Sources   Download

MIT

feature toggle flag

12/02 2014

v0.1.0

0.1.0.0

  Sources   Download

MIT

feature toggle flag

12/02 2014

v0.0.1

0.0.1.0

  Sources   Download

MIT

feature toggle flag