PHPackages                             fraserreed/feature-flag - 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. fraserreed/feature-flag

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

fraserreed/feature-flag
=======================

Simple feature flag checking for PHP &gt;=5.5

v0.3(10y ago)022MITPHPPHP &gt;=5.5

Since Sep 15Pushed 10y ago1 watchersCompare

[ Source](https://github.com/fraserreed/feature-flag)[ Packagist](https://packagist.org/packages/fraserreed/feature-flag)[ Docs](http://github.com/fraserreed/feature-flag)[ RSS](/packages/fraserreed-feature-flag/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

FeatureFlag
===========

[](#featureflag)

Simple feature flag checking for PHP &gt;=5.5.

[![Build Status](https://camo.githubusercontent.com/62007f2330734e56b4304f7a264687a79e681b8af9741a9a76df390a76267d58/68747470733a2f2f7472617669732d63692e6f72672f667261736572726565642f666561747572652d666c61672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/fraserreed/feature-flag)[![Coverage Status](https://camo.githubusercontent.com/06490356500610eed0d8856f3e788b9dc40c74312137bc2cdfd42ea7389e81f8/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f667261736572726565642f666561747572652d666c61672f62616467652e706e673f6272616e63683d6d6173746572)](https://coveralls.io/r/fraserreed/feature-flag?branch=master)

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

[](#installation)

Install this package in your application using [composer](http://composer.org).

In the require section, add the following dependency:

```
"fraserreed/feature-flag": "~0.2"

```

Usage
-----

[](#usage)

Any of these approaches can be extended and put in a view helper in most frameworks.

### Static Configuration

[](#static-configuration)

For static, array based feature flags, ideally used in multi-environment deploys.

First create the static filter:

```
$config = [
    'feature-one'   => true,
    'feature-two'   => false,
    'feature-three' => true,
    'feature-four'  => true
];

$featureFlagFilter = new \FeatureFlag\Filter\Simple( $config );

```

Then assert that a feature is enabled or not:

```
$featureFlag = new \FeatureFlag\FeatureFlag( $featureFlagFilter );

echo (int) $featureFlag->isEnabled( 'feature-one' ) . " should be true\n";
echo (int) $featureFlag->isEnabled( 'feature-two' ) . " should be false\n";
echo (int) $featureFlag->isEnabled( 'feature-three' ) . " should be true\n";
echo (int) $featureFlag->isEnabled( 'feature-four' ) . " should be true\n";
echo (int) $featureFlag->isEnabled( 'feature-five' ) . " should be false (doesn't exist)\n";

```

### Distributed IP Address Weighting

[](#distributed-ip-address-weighting)

For an expected distribution across the IPv4 spectrum, a weighted configuration can be used. A `crc32` hash checksum is computed for the IP, modulo 100.

First create the filter with the expected distribution factor.

```
//feature flag will be enabled 75% of the time
$featureFlagFilter = new \FeatureFlag\Filter\DistributedIp( 75 );

```

Then assert that a feature is enabled or not:

```
$featureFlag = new \FeatureFlag\FeatureFlag( $featureFlagFilter );

echo (int) $featureFlag->isEnabled( 'feature-one', '192.168.0.161' ) . " should be false\n";
echo (int) $featureFlag->isEnabled( 'feature-one', '31.12.127.255' ) . " should be true\n";
echo (int) $featureFlag->isEnabled( 'feature-one', '46.248.224.183' ) . " should be true\n";
echo (int) $featureFlag->isEnabled( 'feature-one', '58.136.218.102' ) . " should be true\n";

```

Tests
-----

[](#tests)

To run the tests you'll need to have phpunit installed.

Running the tests:

```
$ phpunit

```

Contributing
------------

[](#contributing)

For any issues, submit an issue via this repo. For contributing please fork and submit PRs.

License
-------

[](#license)

MIT, see LICENSE.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

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

Every ~1 days

Total

3

Last Release

3898d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/cfa5756fb63308a26f4805a3f8bd909ef4b2d96416766463fce9587e924e6b61?d=identicon)[fraserreed](/maintainers/fraserreed)

---

Top Contributors

[![fraserreed](https://avatars.githubusercontent.com/u/3450927?v=4)](https://github.com/fraserreed "fraserreed (2 commits)")

---

Tags

feature flag

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/fraserreed-feature-flag/health.svg)

```
[![Health](https://phpackages.com/badges/fraserreed-feature-flag/health.svg)](https://phpackages.com/packages/fraserreed-feature-flag)
```

###  Alternatives

[remotelyliving/doorkeeper

A Feature Toggle

1636.9k](/packages/remotelyliving-doorkeeper)[awcodes/palette

A color picker field for Filament Forms that uses preset color palettes.

2552.6k5](/packages/awcodes-palette)

PHPackages © 2026

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