PHPackages                             niborb/php-feature-toggle - 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. niborb/php-feature-toggle

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

niborb/php-feature-toggle
=========================

A PHP Feature toggle library

1.0.1(10y ago)5518MITPHPPHP &gt;=5.5

Since Jul 5Pushed 10y ago2 watchersCompare

[ Source](https://github.com/niborb/php-feature-toggle)[ Packagist](https://packagist.org/packages/niborb/php-feature-toggle)[ RSS](/packages/niborb-php-feature-toggle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (4)Used By (0)

PHP 5 feature toggle library
----------------------------

[](#php-5-feature-toggle-library)

[![Build Status](https://camo.githubusercontent.com/9ab5b1ee87856b3f1e484699c38b40ccb75c34155dbe15f208a577ae84af8840/68747470733a2f2f7472617669732d63692e6f72672f6e69626f72622f7068702d666561747572652d746f67676c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/niborb/php-feature-toggle)[![Coverage Status](https://camo.githubusercontent.com/11262a156ea0b87921697fe824282192adb9874b9afa1c567c583fc50670bb10/68747470733a2f2f696d672e736869656c64732e696f2f636f766572616c6c732f6e69626f72622f7068702d666561747572652d746f67676c652e737667)](https://coveralls.io/r/niborb/php-feature-toggle)

### Installation

[](#installation)

You can install the library with Composer.

```
composer.phar require "niborb/php-feature-toggle"

```

or check packagist.org:

### Example (see also the examples directory)

[](#example-see-also-the-examples-directory)

```
require 'vendor/autoload.php';

require 'User.php';

use Doctrine\Common\Cache\ArrayCache;
use Niborb\FeatureToggle\Cache\CacheProxy;
use Niborb\FeatureToggle\Entity\Feature;
use Niborb\FeatureToggle\Toggle;
use Symfony\Component\ExpressionLanguage\ExpressionLanguage;

$toggle = new Toggle();
$toggle->setExpressionLanguage(
    new ExpressionLanguage(
        new CacheProxy(
            new ArrayCache()
        )
    )
);

// new user interface only available for users with an ID in range (1000-2000)
$feature = new Feature('user-interface-2.0');
$feature->enable();
$feature->setExpression('user.getId() in 1000..2000');

// add user to the toggle manager
$toggle->addFeature($feature);

// some users as context
$userOne = new User(3000);
$userTwo = new User(1500);

// check for both users if the feature is enabled

foreach ([$userOne, $userTwo] as $user) {
    if ($toggle->isEnabled('user-interface-2.0', ['user' => $user])
    ) {
        echo "User " . $user->getId() . " can see new interface" . PHP_EOL;
    } else {
        echo "User " . $user->getId() . " cannot(!) see new interface" . PHP_EOL;
    }
}
```

Output:

```
User 3000 cannot(!) see new interface
User 1500 can see new interface

```

### PHPSpec

[](#phpspec)

The library contains PHPSpec tests (./spec). Clone the repository and run:

```
vendor/bin/phpspec run

```

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 96% 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 ~126 days

Total

2

Last Release

3844d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/12b6f2115a8cfea574658abed850fc2eecd34656c03947d3ae302cceaf43cb7c?d=identicon)[niborb](/maintainers/niborb)

---

Top Contributors

[![niborb](https://avatars.githubusercontent.com/u/1757473?v=4)](https://github.com/niborb "niborb (24 commits)")[![robin-sqills](https://avatars.githubusercontent.com/u/160146066?v=4)](https://github.com/robin-sqills "robin-sqills (1 commits)")

### Embed Badge

![Health badge](/badges/niborb-php-feature-toggle/health.svg)

```
[![Health](https://phpackages.com/badges/niborb-php-feature-toggle/health.svg)](https://phpackages.com/packages/niborb-php-feature-toggle)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

22.8k69.3k](/packages/grumpydictator-firefly-iii)[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[verbb/formie

The most user-friendly forms plugin for Craft.

101372.9k40](/packages/verbb-formie)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[eliashaeussler/typo3-form-consent

Extension for TYPO3 CMS that adds double opt-in functionality to EXT:form

1481.0k](/packages/eliashaeussler-typo3-form-consent)

PHPackages © 2026

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