bestit / feature-toggle-bundle
4.3.0
2022-04-22 13:52 UTC
Requires
- php: ^7.1.3 | ^8
- doctrine/annotations: ^1.7
- flagception/flagception: ^1.5
- symfony/config: ^4.4 | ^5.0 | ^6.0
- symfony/dependency-injection: ^4.4 | ^5.0 | ^6.0
- symfony/http-kernel: ^4.4 | ^5.0 | ^6.0
- symfony/yaml: ^4.4 | ^5.0 | ^6.0
- twig/twig: ^1.18|^2.0|^3.0
Requires (Dev)
- flagception/database-activator: ^1.0
- php-coveralls/php-coveralls: ^2.0
- squizlabs/php_codesniffer: ^3.3.1
- symfony/phpunit-bridge: ^5.0 | ^6.0
- symfony/twig-bridge: ^4.4 | ^5.0 | ^6.0
Suggests
- flagception/contentful-activator: Fetch feature flags from contentful.
- flagception/database-activator: Fetch feature flags from a database.
README
功能开关包增强版! Flagception 是一个简单而强大的 PHP 功能开关系统。此包集成了 Flagception PHP 库,用于 symfony 2.7 到 5.*(以及 php 5.6 到 php7.*)。
包版本(标签) | 支持 Symfony | 分支 |
---|---|---|
<=3 | 2.7 - 4.4 | 3.x |
>=4 | 4.4 - 当前 | master |
$ composer require flagception/flagception-bundle
文档
快速示例
在您的配置中设置一些功能(或使用您自己的 激活器 从您想要的任何地方获取功能)...
flagception: # Your Features (optional you left it empty) features: # Feature name as key feature_123: # Default flag if inactive or active (default: false) default: true # Feature state from an environment variable feature_abc: env: FEATURE_ENV_ABC # Feature with constraint (active if user id is 12 OR it is between 8 am and 6 pm) feature_def: constraint: 'user_id == 12 or (date("H") > 8 and date("H") < 18)' # All togther (chain) feature_def: default: false env: FEATURE_ENV_ABC constraint: 'user_id == 12 or (date("H") > 8 and date("H") < 18)'
...然后在控制器、服务或 Twig 中使用它
{% if feature('feature_123') %} {# Execute if feature is active ... #} {% endif %}
请参阅 使用文档 获取详细示例。
分析器
此包提供了一个分析器标签页,您可以在其中查看功能被请求的频率,它返回的结果(活动或非活动)以及给定的上下文。