getphred/flagpole
最新稳定版本:v0.1.0
Composer 安装命令:
composer require getphred/flagpole
包简介
Feature flag handling library for PHP. Simple, fast, and framework-agnostic.
README 文档
README
Feature flag handling for PHP. Simple, framework-agnostic, and lightweight.
Installation
Install via Composer:
composer require phred/flagpole
Quick start
use FlagPole\FeatureManager; use FlagPole\Context; use FlagPole\Repository\InMemoryFlagRepository; require __DIR__ . '/vendor/autoload.php'; $repo = InMemoryFlagRepository::fromArray([ 'new-dashboard' => [ 'enabled' => null, // not a hard on/off 'rolloutPercentage' => 25, // 25% gradual rollout 'allowList' => ['user_1'], // always on for specific users 'rules' => [ // attribute-based rules ['attribute' => 'plan', 'operator' => 'eq', 'value' => 'pro'], ], ], 'hard-off' => [ 'enabled' => false ], 'hard-on' => [ 'enabled' => true ], ]); $flags = new FeatureManager($repo); $context = Context::fromArray(['userId' => 'user_42', 'plan' => 'pro']); if ($flags->isEnabled('new-dashboard', $context, false)) { // show the new dashboard } else { // keep the old dashboard }
Concepts
- Flag: has a
nameand optional strategies:enabled: explicit boolean on/off overrides everything.allowList: list of user keys that always get the flag enabled.rules: complex attribute targeting (e.g.version > 2.0,plan == 'pro').rolloutPercentage: 0-100 gradual rollout based on a stable hash.
- Context: attributes about the subject (e.g.
userId,email) used for evaluation. - Repository: source of truth for flags. Provided:
InMemoryFlagRepository,JsonFileRepository. - Hydration:
FlagHydratorcentralizes flag creation and provides validation for targeting rules. - Observability: Optional PSR-3 logging of evaluation results and reasons.
Targeting key
Evaluator looks for a stable key in the context in this order: key, userId, id, email.
You can also specify an explicit targetingKey per flag to use a specific attribute (e.g. orgId).
Precedence semantics
When evaluating a flag, the following precedence applies:
allowList— if the targeting key is in the allow-list, the flag is enabled.enabled— explicit on/off overrides everything below.rules— attribute-based targeting rules.rolloutPercentage— uses stable bucketing over the targeting key.- Fallback — returns the provided default when none of the above apply.
Framework integration
FlagPole is framework-agnostic. Wrap FeatureManager in your framework's container and bind a repository suitable for your environment.
License
MIT
getphred/flagpole 适用场景与选型建议
getphred/flagpole 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 12 月 10 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「flags」 「toggle」 「rollout」 「feature-flags」 「ab-testing」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 getphred/flagpole 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 getphred/flagpole 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 getphred/flagpole 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Laravel Eloquent boolean & timestamp flagged attributes behavior.
ZF2 module for the Opensoft Rollout library
A PHP trait to enable bitwise comparison of flags
yii2 toggle column for update in gridview
Adds flags support to your model/entity
统计信息
- 总下载量: 1
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 20
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-12-10