opensoft/rollout
Composer 安装命令:
composer require opensoft/rollout
包简介
Feature switches or flags for PHP
README 文档
README
Feature flippers for PHP. A port of ruby's rollout.
Install It
composer require opensoft/rollout
How it works
Initialize a rollout object:
use Opensoft\Rollout\Rollout; use Opensoft\Rollout\Storage\ArrayStorage; $rollout = new Rollout(new ArrayStorage());
Check if a feature is active for a particular user:
$rollout->isActive('chat', $user); // returns true/false
Check if a feature is activated globally:
$rollout->isActive('chat'); // returns true/false
Storage
There are a number of different storage implementations for where the configuration for the rollout is stored.
- ArrayStorage - default storage, not persistent
- DoctrineCacheStorageAdapter - requires doctrine/cache
- PDOStorageAdapter - persistent using PDO
- RedisStorageAdapter - persistent using Redis
- MongoDBStorageAdapter - persistent using Mongo
All storage adapters must implement Opensoft\Rollout\Storage\StorageInterface.
Groups
Rollout ships with one group by default: all, which does exactly what it sounds like.
You can activate the all group for chat features like this:
$rollout->activateGroup('chat', 'all');
You may also want to define your own groups. We have one for caretakers:
$rollout->defineGroup('caretakers', function(RolloutUserInterface $user = null) { if (null === $user) { return false; } return $user->isCaretaker(); // boolean });
You can activate multiple groups per feature.
Deactivate groups like this:
$rollout->deactivateGroup('chat');
Specific Users
You may want to let a specific user into a beta test or something. If that user isn't part of an existing group, you can let them in specifically:
$rollout->activateUser('chat', $user);
Deactivate them like this:
$rollout->deactivateUser('chat', $user);
Rollout users must implement the RolloutUserInterface.
User Percentages
If you're rolling out a new feature, you may want to test the waters by slowly enabling it for a percentage of your users.
$rollout->activatePercentage('chat', 20);
The algorithm for determining which users get let in is this:
crc32($user->getRolloutIdentifier()) % 100 < $percentage
So, for 20%, users 0, 1, 10, 11, 20, 21, etc would be allowed in. Those users would remain in as the percentage increases.
Deactivate all percentages like this:
$rollout->deactivatePercentage('chat');
Note: Activating a feature for 100% of users will also make it activate globally. This is like calling $rollout->isActive() without a user object.
Feature is Broken
Deactivate everybody at once:
$rollout->deactivate('chat');
You may wish to disable features programmatically if monitoring tools detect unusually high error rates for example.
Remove a Feature (added in 2.0.0)
After a feature becomes mainstream or a failed experiment, you may want to remove the feature definition from rollout.
$rollout->remove('chat');
Note: If there is still code referencing the feature, it will be recreated with default settings.
Symfony2 Bundle
A Symfony2 bundle is available to integrate rollout into Symfony2 projects. It can be found at http://github.com/opensoft/OpensoftRolloutBundle.
Zend Framework 2 Module
A Zend Framework 2 module is availabile to intergrate rollout into Zend Framwork 2 projects. It can be found at https://github.com/adlogix/zf2-opensoft-rollout.
Implementations in other languages
Copyright
Copyright © 2017 James Golick, BitLove, Inc. See LICENSE for details.
opensoft/rollout 适用场景与选型建议
opensoft/rollout 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.93M 次下载、GitHub Stars 达 257, 最近一次更新时间为 2014 年 04 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「flag」 「feature」 「toggle」 「flipper」 「rollout」 「switches」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 opensoft/rollout 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 opensoft/rollout 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 opensoft/rollout 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A block that displays featured content - large image, title, description and link.
Cold template caches that can be flagged and automatically invalidated.
Laravel Eloquent boolean & timestamp flagged attributes behavior.
Bitwise flag setting for Yii 2.x
MaxAl Subscriptions is a flexible plans and subscription management system for Laravel, with the required tools to run your SAAS like services efficiently. It's simple architecture, accompanied by powerful underlying to afford solid platform for your business.
Country Flag Emoji for PHP
统计信息
- 总下载量: 1.93M
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 261
- 点击次数: 21
- 依赖项目数: 5
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2014-04-04