PHPackages                             getphred/flagpole - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. getphred/flagpole

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

getphred/flagpole
=================

Feature flag handling library for PHP. Simple, fast, and framework-agnostic.

v0.1.0(5mo ago)01MITPHPPHP &gt;=8.1CI passing

Since Dec 9Pushed 3mo agoCompare

[ Source](https://github.com/getphred/flagpole)[ Packagist](https://packagist.org/packages/getphred/flagpole)[ Docs](https://github.com/phred/flagpole)[ RSS](/packages/getphred-flagpole/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (2)Used By (0)

FlagPole
========

[](#flagpole)

Feature flag handling for PHP. Simple, framework-agnostic, and lightweight.

[![CI](https://github.com/getphred/flagpole/actions/workflows/ci.yml/badge.svg)](https://github.com/getphred/flagpole/actions/workflows/ci.yml/badge.svg)[![Packagist](https://camo.githubusercontent.com/611f856c7617708cf40eb5f6446b6f39c4189ed09b879e6e89a851644bb3ee3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67657470687265642f666c6167706f6c652e737667)](https://camo.githubusercontent.com/611f856c7617708cf40eb5f6446b6f39c4189ed09b879e6e89a851644bb3ee3c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f67657470687265642f666c6167706f6c652e737667)[![Total Downloads](https://camo.githubusercontent.com/4a6e92e65834c34a13fc97ca1f125c43419e1bd2fea952732ed8e6137d5c80d2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f67657470687265642f666c6167706f6c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/getphred/pairity)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

Installation
------------

[](#installation)

Install via Composer:

```
composer require phred/flagpole

```

Quick start
-----------

[](#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
--------

[](#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
-------------

[](#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
--------------------

[](#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
---------------------

[](#framework-integration)

FlagPole is framework-agnostic. Wrap `FeatureManager` in your framework's container and bind a repository suitable for your environment.

License
-------

[](#license)

MIT

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance78

Regular maintenance activity

Popularity1

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity33

Early-stage or recently created project

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

160d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/76918287c4577d7b4a6713f0d54f3de11e0d6a86f88bb2883b5dd0a19f80d87f?d=identicon)[getphred](/maintainers/getphred)

---

Tags

phpflagstogglerolloutfeature-flagsab-testing

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/getphred-flagpole/health.svg)

```
[![Health](https://phpackages.com/badges/getphred-flagpole/health.svg)](https://phpackages.com/packages/getphred-flagpole)
```

###  Alternatives

[flagception/flagception-bundle

Feature toggle bundle on steroids.

283.8M](/packages/flagception-flagception-bundle)[opensoft/rollout

Feature switches or flags for PHP

2571.8M5](/packages/opensoft-rollout)[flagception/flagception

Feature toggle on steroids.

134.3M5](/packages/flagception-flagception)[ajgarlag/feature-flag-bundle

Provides a feature flag mechanism

1417.8k](/packages/ajgarlag-feature-flag-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
