hotflo / feature-toggle-bundle
实现 https://github.com/JoshuaEstes/FeatureToggle 库的 Symfony2 Bundle
此包的官方仓库似乎已不存在,因此该包已被冻结。
v0.1.1
2015-07-07 07:56 UTC
Requires
- php: >=5.4.0
- joshuaestes/feature-toggle: ^0.3
- symfony/framework-bundle: >=2.0
Requires (Dev)
This package is not auto-updated.
Last update: 2022-04-02 04:57:37 UTC
README
实现 https://github.com/JoshuaEstes/FeatureToggle 库的 Symfony2 Bundle
安装
使用 composer 安装
composer.phar require hotflo/feature-toggle-bundle
将以下内容添加到您的 AppKernel.php
new Hotflo\FeatureToggleBundle\HotfloFeatureToggleBundle(),
配置
要使用此 Bundle,您应在 config.yml 中配置开关和功能。您可以使用一个类或服务作为开关,然后使用配置的开关在您的功能中使用。
完整参考
hotflo_feature_toggle:
toggles:
generic:
class: JoshuaEstes\Component\FeatureToggle\Toggle\FeatureToggleGeneric
options:
enabled: true
generic_service:
type: service
service: hotflo_feature_toggle.generic_feature_toggle
features:
dashboard:
toggle: generic_service
使用方法
在您的控制器中,功能容器可在 Symfony2 服务容器中使用。
示例
$this->get('hotflo_feature_toggle.feature_container')->getFeature('dashboard');
配置的功能开关也可在 Symfony2 服务容器中使用。
$this->get('hotflo_feature_toggle.feature_toggle_container')->getFeatureToggle('generic');
测试
通过运行 PHP Unit 启动测试
./bin/phpunit
更多文档
此 Bundle 依赖于 FeatureToggle 库。该库的文档可以在以下位置找到: http://feature-toggle.readthedocs.org/en/latest/