• Stars
    star
    253
  • Rank 160,313 (Top 4 %)
  • Language
    PHP
  • License
    MIT License
  • Created over 10 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Feature switches or flags for PHP

rollout (for php)

Build Status Scrutinizer Code Quality Code Coverage

Feature flippers for PHP. A port of ruby's rollout.

Install It

composer require opensoft/rollout

How it works

Initialize a rollout object:

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

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

Check if a feature is active for a particular user:

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

Check if a feature is activated globally:

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

Storage

There are a number of different storage implementations for where the configuration for the rollout is stored.

  • 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.

Groups

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

You can activate the all group for chat features like this:

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

You may also want to define your own groups. We have one for caretakers:

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

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

You can activate multiple groups per feature.

Deactivate groups like this:

$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:

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

Deactivate them like this:

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

Rollout users must implement the RolloutUserInterface.

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.

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

The algorithm for determining which users get let in is this:

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.

Deactivate all percentages like this:

$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.

Feature is Broken

Deactivate everybody at once:

$rollout->deactivate('chat');

You may wish to disable features programmatically if monitoring tools detect unusually high error rates for example.

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.

$rollout->remove('chat');

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

Symfony2 Bundle

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

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.

Implementations in other languages

Copyright

Copyright © 2017 James Golick, BitLove, Inc. See LICENSE for details.

More Repositories

1

doctrine-postgres-types

Provide common Doctrine types for Postgres in use at Opensoft
PHP
68
star
2

OpensoftRolloutBundle

A Symfony2 Bundle for opensoft/rollout
PHP
42
star
3

simple-serializer

Simple serializer
PHP
18
star
4

php-wsdl-proxy-generator

WSDL parser and Proxy class generator on PHP
PHP
13
star
5

proofseed

Seed of Proof
C++
13
star
6

proofbase

Base of Proof
C++
11
star
7

epl

PHP
10
star
8

OpensoftSimpleSerializerBundle

Simple PHP Serializer bundle for Symfony 2.*
PHP
9
star
9

AsterBunny

Send json encoded Asterisk AMI events to RabbitMQ exchanges
PHP
8
star
10

OpensoftEZCWorkflow

A PHP 5.3 port of the ezc workflow component
PHP
8
star
11

jquery-draggable-pagination

Paginate your list with flick and drag-and-snap navigation. ThemeRoller ready.
JavaScript
7
star
12

proof-oss

Open source subset of Proof
CMake
6
star
13

proof-docker

Dockerfiles for Proof-related stuff in DockerHub
Shell
5
star
14

proofnetworkjdf

Proof JDF support
C++
4
star
15

json-streaming-parser

PSR-7 json streaming parser
PHP
4
star
16

OpensoftStorageBundle

A bundle for tracking stored files across local and cloud based storages
JavaScript
4
star
17

proofutils

Set of proof modules used by almost all stations/services
C++
3
star
18

proof-restarter

Autostart for proof-based projects
Shell
3
star
19

proofboot

Various scripts and bits to build proof modules
Shell
3
star
20

InkRouter-PHP-SDK

PHP SDK for InkRouter
PHP
2
star
21

jquery-event-chr-seq

A jQuery plugin to handle complex character sequences
JavaScript
2
star
22

proof-gtest

GoogleTest fork with extra stuff for testing Proof
C++
2
star
23

proofservice-lpr-printer

Proof-based service for remote labels printing
C++
2
star
24

phools

PHP Library for communicating via REST to a Drools Execution Server 5.1
PHP
1
star
25

OpensoftEplBundle

Bundle for the epl library
PHP
1
star
26

sismo-configurator

Plugin for Sismo (http://sismo.sensiolabs.org), brings the ability to generate a configuration file (config.php) based on .travis.yml or .sismo.yml
1
star
27

OpensoftDoctrineOXMBundle

Bundle for the Doctrine OXM project (deprecated) - use https://github.com/doctrine/DoctrineOXMBundle
PHP
1
star
28

proofservice-weighing-scale

Proxy service for working with weighing scales (only HID-compatible for now)
C++
1
star