A PHP client for the Bandiera feature flagging service
PHP
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
spec/Nature/Bandiera
src
.gitignore
.travis.yml
LICENSE.txt
README.md
composer.json
composer.lock

README.md

Bandiera PHP Client

This is a client for talking to the Bandiera feature flagging service from a PHP application.

This client is compatible with the v2 Bandiera API.

Build status MIT licensed

Installation

Installation is done via composer. In your composer.json file add:

{
    "require": {
        "npg/bandiera-client-php": "~1.0"
    }
}

Usage

You can interact with the Bandiera server like so:

<?php

include 'vendor/autoload.php';

$bandiera = new Nature\Bandiera\Client('http://bandiera-demo.herokuapp.com');

if ($bandiera->isEnabled('my_app', 'super_new_feature')) {
    // show the super new feature!
}

The Nature\Bandiera\Client::isEnabled command takes two main arguments - the 'feature group', and the 'feature name'. This is because in Bandiera, features are organised into groups as it is intented as a service for multiple applications to use at the same time - this organisation allows separation of feature flags that are intended for different audiences.

Nature\Bandiera\Client::isEnabled also takes an optional params array, this is for use with some of the more advanced features in Bandiera - user group and percentage based flags. It is in this params array you pass in your user_group and user_id, i.e.:

$bandiera->isEnabled('my_app', 'super_new_feature', [
    'user_id' => 1234567,
    'user_group' => 'Administrators'
]);

For more information on these advanced features, please see the Bandiera wiki:

https://github.com/springernature/bandiera/wiki/How-Feature-Flags-Work#feature-flags-in-bandiera

Direct API Access

If you'd prefer not to use the isEnabled method for featching feature flag values, the following methods are available...

Get features for all groups:

Nature\Bandiera\Client::getAll($params = []);

Get features for a group:

Nature\Bandiera\Client::getFeaturesForGroup($group, $params = []);

Get an individual feature:

Nature\Bandiera\Client::getFeature($group, $feature, $params = []);

Development

  1. Fork this repo.
  2. Run composer install

License

© 2014 Springer Nature. Bandiera PHP Client is licensed under the MIT License.