symfgenus / flagception-bundle
功能切换包的强化版本。
dev-master
2023-11-30 07:30 UTC
Requires
- php: ^7.1.3 | ^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.
This package is auto-updated.
Last update: 2024-09-18 17:28:23 UTC
README
功能切换包的强化版本! Flagception 是一个简单而强大的 php 功能切换系统。此包集成了 Flagception PHP 库,用于 symfony 2.7 到 6.* (以及 php 5.6 到 php 8.*).
$ 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 %}
查看 使用文档 获取详细示例。
性能分析器
此包包含一个性能分析标签页,您可以在此处查看功能请求的频率、返回的结果(激活或未激活)以及提供的上下文。