npg/bandiera-client-php

此包已被弃用,不再维护。未建议替代包。

Bandiera是一个简单独立的特性标志服务,不依赖于任何现有的Web框架或语言。这是一个与Web服务通信的客户端。

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

这是一个PHP应用程序与Bandiera特性标志服务通信的客户端。

此客户端与v2 Bandiera API兼容。

Build status MIT licensed

安装

安装通过composer完成。在您的composer.json文件中添加

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

使用

您可以像这样与Bandiera服务器交互

<?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!
}

Nature\Bandiera\Client::isEnabled命令接受两个主要参数 - '特性组'和'特性名称'。这是因为Bandiera中的特性组织成组,它被设计为多个应用程序同时使用的服务 - 这种组织允许分离针对不同受众的特性标志。

Nature\Bandiera\Client::isEnabled还接受一个可选的params数组,这是用于Bandiera中的一些更高级特性 - 用户组和基于百分比的标志。您可以在此params数组中传递您的user_groupuser_id,即

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

有关这些高级特性的更多信息,请参阅Bandiera wiki

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

直接API访问

如果您不希望使用isEnabled方法获取特性标志值,以下方法可用...

获取所有组的特性

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

获取组的特性

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

获取单个特性

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

开发

  1. 复制此存储库。
  2. 运行composer install

许可证

© 2014 Springer Nature。Bandiera PHP客户端在MIT许可证下授权。