承接 getphred/flagpole 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

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.

CI Packagist Total Downloads Software License

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 name and 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: FlagHydrator centralizes 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:

  1. allowList — if the targeting key is in the allow-list, the flag is enabled.
  2. enabled — explicit on/off overrides everything below.
  3. rules — attribute-based targeting rules.
  4. rolloutPercentage — uses stable bucketing over the targeting key.
  5. 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 我们能提供哪些服务?
定制开发 / 二次开发

基于 getphred/flagpole 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 1
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 20
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-12-10