jonathanbird/feature-switch
Composer 安装命令:
composer require jonathanbird/feature-switch
包简介
Feature switching made easy
README 文档
README
Need to wrap new features for dev and production? Use a directive in the view or alias in the controller
There's great libraries in Java and other languages, but I found a real lack of good libraries to do this in PHP, so I've created my own.
Installation
Add the following line to the require section of composer.json:
{
"require": {
"jonathanbird/feature-switch": "dev-master"
}
}
or composer require jonathanbird/feature-switch
Setup
- Add
'JonathanBird\FeatureSwitch\FeatureSwitchServiceProvider',to the service provider list inapp/config/app.php. - Run
php artisan vendor:publishto publish the features config file toconfig/feature-switch/features.php
Usage
- In the view, you can use the directive
@feature('feature_name') something @endfeature(note@elsealso works for when a feature is not enabled) - In your controller or anywhere, simply add
use Feature;to the top of your file and use the aliasFeature::isEnabled('feature_one')which returns a boolean value - To add features, add your feature name and boolean value to
config/feature-switch/features.php
Why would I use this over git merging?
If you have multiple environments (e.g. three test environments, staging and production) and you want to have the code base in a state of continuous deployment, then you may wish to branch your feature, wrap it within feature switch, merge it in to master branch, and when it gets to staging or production and you realise there's a bug, you can simply switch the feature off without it causing an issue rather than having to remove code from a merge. This is also works well for launching a feature as it's a simple on/off switch - simply git ignore the features.php file to have a different one in each environment.
Issues
If you find an issue, please report it. If it's something you can fix, fork the project and use a pull request as it'll be much quicker.
jonathanbird/feature-switch 适用场景与选型建议
jonathanbird/feature-switch 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34.57k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2016 年 06 月 07 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 jonathanbird/feature-switch 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 jonathanbird/feature-switch 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 34.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 26
- 点击次数: 3
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-06-07