npg/bandiera-client-php

This package is abandoned and no longer maintained. No replacement package was suggested.

Bandiera is a simple, stand-alone feature flagging service that is not tied to any existing web framework or language. This is a client for talking to the web service.

1.0.1 2015-07-07 11:25 UTC

This package is not auto-updated.

Last update: 2022-02-08 20:14:09 UTC


README

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.