medigo / laika
2.1.0
2018-01-18 16:44 UTC
Requires
- guzzlehttp/guzzle: ~6.3
Requires (Dev)
- phake/phake: @stable
This package is not auto-updated.
Last update: 2024-09-14 18:58:40 UTC
README
laika-php 是一个PHP库,它将应用程序与Laika功能标志服务(https://github.com/MEDIGO/laika)连接起来。它用于使应用程序知道当前环境中激活了哪些标志并适应它。
设置
添加
"medigo/laika": "dev-master"
到 composer.json 并运行
php composer.phar update
使用方法
当使用Laika时,您需要在环境中配置
- 环境名称 - 执行代码的环境(例如 "test" 或 "dev")。
- url - API服务器的URL。
- 用户名(可选)- 基本认证的用户名。
- 密码(可选)- 基本认证的密码。
初始化库并从数据库中获取所有功能
public function __construct($environment, $host, $username, $password)
{
$this->client = new Laika($environment, $host, $username, $password);
$this->client->fetchAllFeatures();
return $this->client;
}
使用 isEnabled() 函数来了解标志是否在当前环境中激活。
$myVar = 'the flag is disabled';
if ($laika->isEnabled('FLAG_NAME')) {
$myVar = 'the flag is enabled';
}
测试库
运行
phpunit tests/LaikaTest.php
版权和许可
版权 © 2017 MEDIGO GmbH。
Laika 在MIT许可证下授权。有关完整许可文本,请参阅 LICENSE。