flagception / flagception-bundle
功能切换包的增强版。
5.0.1
2024-08-05 08:04 UTC
Requires
- php: ^8.0
- doctrine/annotations: ^1.7 | ^2.0
- flagception/flagception: ^1.5
- symfony/config: ^4.4 | ^5.0 | ^6.0 | ^7.0
- symfony/dependency-injection: ^4.4 | ^5.0 | ^6.0 | ^7.0
- symfony/http-kernel: ^4.4 | ^5.0 | ^6.0 | ^7.0
- symfony/yaml: ^4.4 | ^5.0 | ^6.0 | ^7.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 | ^7.0
- symfony/twig-bridge: ^4.4 | ^5.0 | ^6.0 | ^7.0
Suggests
- flagception/database-activator: Fetch feature flags from a database.
README
功能切换包的增强版! Flagception 是一个简单而强大的 PHP 功能切换系统。此包集成了适用于 symfony 2.7 到 6.*(以及 php 5.6 到 php 8.*)的 Flagception PHP 库。
$ 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 %}
请参阅 用法文档 了解详细示例。
分析器
此包包含一个分析器标签页,您可以在其中查看功能被请求的频率、它返回的结果(活动或非活动)以及给定上下文。
致谢
来自 https://github.com/ionic-team/ionicons 的分析器图标