PHPackages                             flagception/flagception - 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. [Testing &amp; Quality](/categories/testing)
4. /
5. flagception/flagception

ActiveLib[Testing &amp; Quality](/categories/testing)

flagception/flagception
=======================

Feature toggle on steroids.

2.0.0(1y ago)154.5M↓53.5%3[2 issues](https://github.com/playox/flagception-sdk/issues)5MITPHPPHP ^7.2||^8.0CI passing

Since Dec 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/playox/flagception-sdk)[ Packagist](https://packagist.org/packages/flagception/flagception)[ RSS](/packages/flagception-flagception/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (3)Dependencies (5)Versions (14)Used By (5)

Flagception
===========

[](#flagception)

Flagception is a simple and powerful feature toggle library. Only a few lines of configuration necessary - and still very flexible and expandable.

[![Latest Stable Version](https://camo.githubusercontent.com/c0a7e8eb3a58dc08265f24c956a8dda477c29a23b0e86fda1ab7cb0be6d8fa78/68747470733a2f2f706f7365722e707567782e6f72672f666c616763657074696f6e2f666c616763657074696f6e2f762f737461626c65)](https://packagist.org/packages/flagception/flagception)[![Coverage Status](https://raw.githubusercontent.com/playox/flagception-sdk/image-data/coverage.svg)](https://raw.githubusercontent.com/playox/flagception-sdk/image-data/coverage.svg)[![Build Status](https://github.com/playox/flagception-sdk/actions/workflows/php.yml/badge.svg)](https://github.com/playox/flagception-sdk/actions)[![Total Downloads](https://camo.githubusercontent.com/d93421ad7f95ef0765306b1db24fee0c0ea78930216bd0df1334d82ce9c0df8d/68747470733a2f2f706f7365722e707567782e6f72672f666c616763657074696f6e2f666c616763657074696f6e2f646f776e6c6f616473)](https://packagist.org/packages/flagception/flagception)[![License](https://camo.githubusercontent.com/fa75cba9ecf477815b9564344a1e19001abc301f4331b2cd5cf0a59ed301cf47/68747470733a2f2f706f7365722e707567782e6f72672f666c616763657074696f6e2f666c616763657074696f6e2f6c6963656e7365)](https://packagist.org/packages/flagception/flagception)

Download the library
--------------------

[](#download-the-library)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this library:

```
$ composer require flagception/flagception
```

Quick example
-------------

[](#quick-example)

Just create a `FeatureManager` instance and pass your activator to start with feature toggling.

```
// MyClass.php
class MyClass
{
    public function doSomething()
    {
        // The activator decide if the feature is active or not
        // You can use your own activator if you implement the interface
        $activator = new ArrayActivator();

        $manager = new FeatureManager($activator);

        if ($manager->isActive('your_feature_name')) {
            // do something
        }
    }
}
```

The activator is the most important class and decide if the given feature is active or not. The `ArrayActivator` needs an array with active feature names as constructor argument. If the requested feature is in array, it will return true otherwise false. Example:

```
// MyClass.php
class MyClass
{
    public function doSomething()
    {
        $activator = new ArrayActivator([
            'feature_abc',
            'feature_def',
            'feature_ghi'
        ]);

        $manager = new FeatureManager($activator);

        // Will return true
        if ($manager->isActive('feature_def')) {
            // do something
        }

        // Will return false
        if ($manager->isActive('feature_wxy')) {
            // do something
        }
    }
}
```

This library ships an [ArrayActivator](docs/activator/array.md), a [ConstraintActivator](docs/activator/constraint.md), a [EnvironmentActivator](docs/activator/environment.md), [CookieActivator](docs/activator/cookie.md)and a [ChainActivator](docs/activator/chain.md).

In most cases you will create your own activator (eg. for doctrine). Just implement the `FeatureActivatorInterface`.

You can use a [CacheActivator](docs/activator/cache.md) if you want to cache the result from some time intensive activators.

Advanced example
----------------

[](#advanced-example)

Sometimes your activator needs more context for deciding if a feature is active or not. You can optionally add a context object as second argument to the manager and check the context data in your activator.

Example:

```
// MyClass.php
class MyClass
{
    public function doSomething(User $user)
    {
        $activator = new YourCustomDoctrineActivator();

        $manager = new FeatureManager($activator);
        $context = new Context();
        $context->add('user_id', $user->getId());

        // Check the feature with context
        if ($manager->isActive('feature_def', $context)) {
            // do something
        }

         // Check the feature without context (result may differ from above)
         if ($manager->isActive('feature_def')) {
             // do something
         }
    }
}

// YourCustomDoctrineActivator.php
class YourCustomDoctrineActivator implements FeatureActivatorInterface
{
    public function isActive($name, Context $context)
    {
        return $context->get('user_id') === 12;
    }
}
```

You can also add the context data globally instead of adding the context to each feature request. Just pass a class which implement the `ContextDecoratorInterface` as second argument for the feature manager constructor:

```
// MyClass.php
class MyClass
{
    public function doSomething(User $user)
    {
        $activator = new YourCustomDoctrineActivator();
        $decorator = new ArrayDecorator([
            'user_id' => $user->getId()
        ]);

        $manager = new FeatureManager($activator, $decorator);

        // Check the feature with the global defined context
        if ($manager->isActive('feature_def')) {
            // do something
        }
    }
}

//YourCustomDoctrineActivator.php
class YourCustomDoctrineActivator implements FeatureActivatorInterface
{
    public function isActive($name, Context $context)
    {
        return $context->get('user_id') === 12;
    }
}
```

You can also mix both variants:

```
// MyClass.php
class MyClass
{
    public function doSomething(User $user)
    {
        $activator = new YourCustomDoctrineActivator();
        $decorator = new ArrayDecorator([
            'user_id' => $user->getId()
        ]);

        $manager = new FeatureManager($activator, $decorator);

        $context = new Context();
        $context->add('user_name', $user->getUsername());

        // Check the feature with the global defined context
        if ($manager->isActive('feature_def', $context)) {
            // do something
        }
    }
}
```

This library ships an [ArrayDecorator](docs/decorator/array.md) and a [ChainDecorator](docs/decorator/chain.md).

###  Health Score

51

—

FairBetter than 95% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity51

Moderate usage in the ecosystem

Community26

Small or concentrated contributor base

Maturity75

Established project with proven stability

 Bus Factor1

Top contributor holds 55.3% 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 ~237 days

Recently: every ~373 days

Total

12

Last Release

492d ago

Major Versions

1.9.1 → 2.0.02025-02-26

PHP version history (3 changes)1.0.0PHP ^5.6||^7.0

1.7.0PHP ^5.6||^7.0||^8.0

1.9.0PHP ^7.2||^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/13180135?v=4)[Michel Chowanski](/maintainers/migo315)[@migo315](https://github.com/migo315)

![](https://avatars.githubusercontent.com/u/4624237?v=4)[Thomas Eiling](/maintainers/teiling88)[@teiling88](https://github.com/teiling88)

![](https://www.gravatar.com/avatar/3862ec1e22034e4c59ae1d5b71806f5307e8ed2bf8a7b5f8feb37a0be786b532?d=identicon)[playox](/maintainers/playox)

---

Top Contributors

[![migo315](https://avatars.githubusercontent.com/u/13180135?v=4)](https://github.com/migo315 "migo315 (42 commits)")[![teiling88](https://avatars.githubusercontent.com/u/4624237?v=4)](https://github.com/teiling88 "teiling88 (18 commits)")[![Schleuse](https://avatars.githubusercontent.com/u/2717384?v=4)](https://github.com/Schleuse "Schleuse (7 commits)")[![mKnoop](https://avatars.githubusercontent.com/u/6775586?v=4)](https://github.com/mKnoop "mKnoop (3 commits)")[![Haehnchen](https://avatars.githubusercontent.com/u/1011712?v=4)](https://github.com/Haehnchen "Haehnchen (2 commits)")[![b3nl](https://avatars.githubusercontent.com/u/1861864?v=4)](https://github.com/b3nl "b3nl (1 commits)")[![calderholding-r](https://avatars.githubusercontent.com/u/110138453?v=4)](https://github.com/calderholding-r "calderholding-r (1 commits)")[![snoob](https://avatars.githubusercontent.com/u/1806237?v=4)](https://github.com/snoob "snoob (1 commits)")[![ajgarlag](https://avatars.githubusercontent.com/u/388184?v=4)](https://github.com/ajgarlag "ajgarlag (1 commits)")

---

Tags

testingflagsfeaturefeature toggletogglerolloutfeature-flagsflagception

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[flagception/flagception-bundle

Feature toggle bundle on steroids.

324.0M](/packages/flagception-flagception-bundle)[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.5k5.9M737](/packages/sylius-sylius)[phpro/grumphp

A composer plugin that enables source code quality checks.

4.3k16.7M1.0k](/packages/phpro-grumphp)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.4M203](/packages/sulu-sulu)[dama/doctrine-test-bundle

Symfony bundle to isolate doctrine database tests and improve test performance

1.2k40.8M217](/packages/dama-doctrine-test-bundle)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)

PHPackages © 2026

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