mohamedahmed01/feature-flag
Composer 安装命令:
composer require mohamedahmed01/feature-flag
包简介
easily switch on and off features using a simple command
README 文档
README
Introduction
Feature Flag is the easiest way to enable and disable features on your different Laravel enviroments it also enable you to do A/B testing and supporting your users with different features sets.
Installtion
- Adding the package using composer
composer require mohamedahmed01/feature-flag
- publishing configuration
php artisan vendor:publish --provider="Mohamedahmed01\FeatureFlag\FeatureFlagServiceProvider" --tag="config"
- Facade is automatically loaded using composer unless you have laravel version < 5.4 you will need to add the facade manually in config/app.php
'FeatureFlag'=> Mohamedahmed01\FeatureFlag\FeatureFlagFacade::class
Usage
//Feature Flagging can be simple done by creating the flag $featureFlag = new FeatureFlag([ 'name' => 'test', 'description' => 'Test feature flag', ]); $featureFlag->save(); //using the flag to scope your your code using if condition or any other way you like if ($featureFlag->isEnabled()) { // Implement the feature for the user } //or you can use the method Targted and checking the audience to match to specific audience if($featureFlag->isTargeted() && in_array($user->id, $featureFlag->getAudience())) { // Implement the feature for the user } //Feature Flagging can be also used to target users based on percentage $featureFlag = new FeatureFlag([ 'name' => 'test', 'description' => 'Test feature flag', 'percentage'=>50 ]); $featureFlag->save(); // you can use the method isEnabledForUser and checking the audience to match to specific audience i.e 50% if($featureFlag->isEnabledForUser($user)) { // Implement the feature for the user } //Feature Flagging can be also used to flag based on datetime $featureFlag = new FeatureFlag([ 'name' => 'test flag', 'finish_date' => '01/04/2023', 'enabled' => true, ]); $featureFlag->save(); // you can use the env either to throw an exception or send a notification when flag expires if($featureFlag->isEnabled()) { // Implement the feature for the user } //then simply call feature-flag:manage followed by the name of your flag to enable Or disable it php artisan feature-flag:manage {flag : The name of the feature flag} {--enable : Enable the feature flag} {--disable : Disable the feature flag}
Configuration :
| Config Name | Description |
|---|---|
| FEATURE_FLAG_DRIVER | Allow you to change the backend driver currently support eleqount |
| FEATURE_FLAG_FINISH_DATE_ACTION | Choose What to do when a date based feature flag expires options "exception,notification" |
| FEATURE_FLAG_NOTIFICATION_EMAIL | set the email to receive on notifications in case you used notification option |
Methods :
| Method | Description |
|---|---|
| getName() | getthe name of the flag |
| getDescription() | get the description of the flag |
| setEnabled(bool) | enable the flag or disable it depending on the value |
| isEnabled() | check if the flag is enabled or not |
| Targted() | check if the flag has specific audience |
| setAudience(array) | set the flag audience by sending array of user's id's i.e [1,2,3,4] |
| getAudience() | get the audience id's of the users for this flag |
| isEnabledForUser($user) | check random user for falling within the percentage |
Contributing
Thank you for considering contributing to Feature-Flag! You can read the contribution guide here.
Testing
composer test
Security
If you discover any security related issues, please email mohamedabdelmenem01@gmail.com instead of using the issue tracker.
License
Feature-Flag is open-sourced software licensed under the MIT license.
mohamedahmed01/feature-flag 适用场景与选型建议
mohamedahmed01/feature-flag 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 105 次下载、GitHub Stars 达 3, 最近一次更新时间为 2023 年 03 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「feature-flag」 「mohamedahmed01」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 mohamedahmed01/feature-flag 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 mohamedahmed01/feature-flag 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 mohamedahmed01/feature-flag 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Feature Flag for WordPress
Lightweight PHP micro-library for probabilistic and deterministic code execution — feature flags, A/B testing, gradual rollouts and sampling.
Set feature flag via .env or cookies
Deterministic A/B testing for Yii3 applications
A powerful module management system for Laravel with dependency resolution, tree structure, and Laravel 13 support
Symfony bundle for OpenFeature PHP SDK
统计信息
- 总下载量: 105
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-21
