Bandiera PHP Client
This is a client for talking to the Bandiera feature flagging service from a PHP application., (*1)
This client is compatible with the v2 Bandiera API., (*2)
, (*3)
Installation
Installation is done via composer. In your composer.json file add:, (*4)
{
"require": {
"npg/bandiera-client-php": "~1.0"
}
}
Usage
You can interact with the Bandiera server like so:, (*5)
<?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., (*6)
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.:, (*7)
$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:, (*8)
https://github.com/springernature/bandiera/wiki/How-Feature-Flags-Work#feature-flags-in-bandiera, (*9)
Direct API Access
If you'd prefer not to use the isEnabled method for featching feature flag values, the following methods are available..., (*10)
Get features for all groups:, (*11)
Nature\Bandiera\Client::getAll($params = []);
Get features for a group:, (*12)
Nature\Bandiera\Client::getFeaturesForGroup($group, $params = []);
Get an individual feature:, (*13)
Nature\Bandiera\Client::getFeature($group, $feature, $params = []);
Development
- Fork this repo.
- Run
composer install
License
© 2014 Springer Nature.
Bandiera PHP Client is licensed under the MIT License., (*14)