2017 © Pedro Peláez
 

library rollout

Feature switches or flags for PHP

image

opensoft/rollout

Feature switches or flags for PHP

  • Monday, October 2, 2017
  • by richardfullmer
  • Repository
  • 5 Watchers
  • 184 Stars
  • 195,087 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 21 Forks
  • 5 Open issues
  • 12 Versions
  • 11 % Grown

The README.md

rollout (for php)

Build Status Scrutinizer Code Quality Code Coverage, (*1)

Feature flippers for PHP. A port of ruby's rollout., (*2)

Install It

composer require opensoft/rollout

How it works

Initialize a rollout object:, (*3)

use Opensoft\Rollout\Rollout;
use Opensoft\Rollout\Storage\ArrayStorage;

$rollout = new Rollout(new ArrayStorage());

Check if a feature is active for a particular user:, (*4)

$rollout->isActive('chat', $user);  // returns true/false

Check if a feature is activated globally:, (*5)

$rollout->isActive('chat'); // returns true/false

Storage

There are a number of different storage implementations for where the configuration for the rollout is stored., (*6)

  • ArrayStorage - default storage, not persistent
  • DoctrineCacheStorageAdapter - requires doctrine/cache
  • PDOStorageAdapter - persistent using PDO
  • RedisStorageAdapter - persistent using Redis
  • MongoDBStorageAdapter - persistent using Mongo

All storage adapters must implement Opensoft\Rollout\Storage\StorageInterface., (*7)

Groups

Rollout ships with one group by default: all, which does exactly what it sounds like., (*8)

You can activate the all group for chat features like this:, (*9)

$rollout->activateGroup('chat', 'all');

You may also want to define your own groups. We have one for caretakers:, (*10)

$rollout->defineGroup('caretakers', function(RolloutUserInterface $user = null) {
  if (null === $user) {
    return false;
  }

  return $user->isCaretaker(); // boolean
});

You can activate multiple groups per feature., (*11)

Deactivate groups like this:, (*12)

$rollout->deactivateGroup('chat');

Specific Users

You may want to let a specific user into a beta test or something. If that user isn't part of an existing group, you can let them in specifically:, (*13)

$rollout->activateUser('chat', $user);

Deactivate them like this:, (*14)

$rollout->deactivateUser('chat', $user);

Rollout users must implement the RolloutUserInterface., (*15)

User Percentages

If you're rolling out a new feature, you may want to test the waters by slowly enabling it for a percentage of your users., (*16)

$rollout->activatePercentage('chat', 20);

The algorithm for determining which users get let in is this:, (*17)

crc32($user->getRolloutIdentifier()) % 100 < $percentage

So, for 20%, users 0, 1, 10, 11, 20, 21, etc would be allowed in. Those users would remain in as the percentage increases., (*18)

Deactivate all percentages like this:, (*19)

$rollout->deactivatePercentage('chat');

Note: Activating a feature for 100% of users will also make it activate globally. This is like calling $rollout->isActive() without a user object., (*20)

Feature is Broken

Deactivate everybody at once:, (*21)

$rollout->deactivate('chat');

You may wish to disable features programmatically if monitoring tools detect unusually high error rates for example., (*22)

Remove a Feature (added in 2.0.0)

After a feature becomes mainstream or a failed experiment, you may want to remove the feature definition from rollout., (*23)

$rollout->remove('chat');

Note: If there is still code referencing the feature, it will be recreated with default settings., (*24)

Symfony2 Bundle

A Symfony2 bundle is available to integrate rollout into Symfony2 projects. It can be found at http://github.com/opensoft/OpensoftRolloutBundle., (*25)

Zend Framework 2 Module

A Zend Framework 2 module is availabile to intergrate rollout into Zend Framwork 2 projects. It can be found at https://github.com/adlogix/zf2-opensoft-rollout., (*26)

Implementations in other languages

  • Ruby: http://github.com/FetLife/rollout
  • Python: http://github.com/asenchi/proclaim

Copyright © 2017 James Golick, BitLove, Inc. See LICENSE for details., (*27)

The Versions

02/10 2017

dev-master

9999999-dev

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

01/08 2017

2.2.1

2.2.1.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

08/11 2016

2.2.0

2.2.0.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

04/10 2016

2.1.1

2.1.1.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

21/09 2016

2.1.0

2.1.0.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

19/11 2015

2.0.1

2.0.1.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

19/11 2015

2.0.0

2.0.0.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

27/10 2015

1.0.4

1.0.4.0

Feature switches or flags for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout switches

09/07 2015

1.0.3

1.0.3.0

Feature flippers for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout

26/03 2015

1.0.2

1.0.2.0

Feature flippers for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout

11/04 2014

1.0.1

1.0.1.0

Feature flippers for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout

04/04 2014

1.0.0

1.0.0.0

Feature flippers for PHP

  Sources   Download

MIT

The Requires

  • php >=5.3.3

 

The Development Requires

feature toggle flag flipper rollout