PHPackages                             nemishkor/toggle-bundle - 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. nemishkor/toggle-bundle

ActiveSymfony-bundle

nemishkor/toggle-bundle
=======================

This Bundle provides the integration with qandidate/toggle. It provides the services and configuration you need to implement feature toggles in your Symfony application.

1.3.1(5y ago)14MITPHPPHP &gt;=7.2

Since Sep 2Pushed 5y agoCompare

[ Source](https://github.com/nemishkor/qandidate-toggle-bundle)[ Packagist](https://packagist.org/packages/nemishkor/toggle-bundle)[ RSS](/packages/nemishkor-toggle-bundle/feed)WikiDiscussions master Synced 6d ago

READMEChangelogDependencies (14)Versions (19)Used By (0)

Qandidate Toggle Symfony Bundle
===============================

[](#qandidate-toggle-symfony-bundle)

This Bundle provides the integration with [our toggle library](https://github.com/qandidate-labs/qandidate-toggle). It provides the services and configuration you need to implement feature toggles in your application.

[![Build Status](https://camo.githubusercontent.com/b103cec1e25b4916533c752d6f52ab6701134b3f899bb5b9f55ba33b5a2e47f3/68747470733a2f2f7472617669732d63692e6f72672f71616e6469646174652d6c6162732f71616e6469646174652d746f67676c652d62756e646c652e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/qandidate-labs/qandidate-toggle-bundle)

About
-----

[](#about)

Read the our blog post series about this repository at:

-
-

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

[](#installation)

### Using Symfony Flex

[](#using-symfony-flex)

The easiest way to install and configure the QandidateToggleBundle with Symfony is by using [Symfony Flex](https://github.com/symfony/flex).

Make sure you have Symfony Flex installed:

```
$ composer require symfony/flex ^1.0
$ composer config extra.symfony.allow-contrib true

```

Install the bundle:

```
$ composer require qandidate/toggle-bundle ^1.0

```

Symfony Flex will automatically register and configure the bundle.

### Manually

[](#manually)

Add the bundle to your composer.json

```
$ composer require qandidate/toggle-bundle ^1.0
```

Add the bundle to your Kernel:

```
$bundles = array(
    // ..
    new Symfony\Bundle\SecurityBundle\SecurityBundle(),
    new Symfony\Bundle\TwigBundle\TwigBundle(),
    new Qandidate\Bundle\ToggleBundle\QandidateToggleBundle(),
);
```

Configuration
-------------

[](#configuration)

```
qandidate_toggle:
    persistence: in_memory|redis|factory|config
    context_factory: null|your.context_factory.service.id
    redis_namespace: toggle_%kernel.environment% # default, only required when persistence = redis
    redis_client: null|your.redis_client.service.id # only required when persistence = redis
    collection_factory: # only required when persistence = factory
        service_id: your.collection_factory.service.id
        method: create
```

Sample Configuration for Symfony
--------------------------------

[](#sample-configuration-for-symfony)

```
qandidate_toggle:
    persistence: config
    toggles:
      always-active-feature:
        name: always-active-feature
        status: always-active
      inactive-feature:
        name: inactive-feature
        status: inactive
        conditions:
      conditionally-active:
        name: conditionally-active
        status: conditionally-active
        conditions:
         - name: operator-condition
           key: user_id
           operator:
               name: greater-than
               value: 42
```

Example usage
-------------

[](#example-usage)

Usage can vary on your application. This example uses the supplied `UserContextFactory`, but you probably need to create your own factory.

```

```

```
// Acme\Controller

public function __construct(
    /* ArticleRepository, Templating, ..*/
    ToggleManager $manager,
    ContextFactory $contextFactory
) {
    // ..
    $this->manager = $manager;
    $this->context = $contextFactory->createContext();
}

// ..

public function articleAction(Request $request)
{
    $this->article = $this->repository->findBySlug($request->request->get('slug'));

    return $this->templating->render('article.html.twig', array(
        'article'        => $article,
        'enableComments' => $this->manager->active('comments', $this->context),
    ));
}
```

You can find a working example using the Symfony [MicroKernelTrait](https://symfony.com/doc/current/configuration/micro_kernel_trait.html)in the [Resources/doc/example](https://github.com/qandidate-labs/qandidate-toggle-bundle/tree/master/Resources/doc/example) directory.

Annotation Usage
----------------

[](#annotation-usage)

You can also use the `@Toggle` annotation on a controller. When the toggle isn't active a 404 exception is thrown.

```
use Qandidate\Bundle\ToggleBundle\Annotations\Toggle;

/**
 * @Toggle("cool-feature")
 */
class FooController
{

    /**
     * @Toggle("another-cool-feature")
     */
    public function barAction()
    {
    }

    public function bazAction()
    {
    }
}
```

Twig usage
----------

[](#twig-usage)

If you use Twig you can also use the function:

```
{% if feature_is_active('comments') %}
    {# Awesome comments #}
{% endif %}
```

Or the Twig test:

```
{% if 'comments' is active feature %}
    {# Awesome comments #}
{% endif %}
```

Both are registered in the [ToggleTwigExtension](Twig/ToggleTwigExtension.php).

Data collector
--------------

[](#data-collector)

With the data collector you have a overview about all toggles. In the toolbar you see all conditions and the current status.

In the panel you have two lists:

- You can see all keys and there current values.
- Then you can see all configured toggles, there conditions and if they are active.

Testing
-------

[](#testing)

To run PHPUnit tests:

```
$ ./vendor/bin/phpunit
```

License
-------

[](#license)

MIT, see LICENSE.

###  Health Score

29

—

LowBetter than 59% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity67

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~140 days

Recently: every ~200 days

Total

17

Last Release

2034d ago

Major Versions

0.8.0 → 1.0.02017-12-10

PHP version history (2 changes)1.0.0PHP &gt;=7.0

1.3.0PHP &gt;=7.2

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/12599510?v=4)[Vitalii](/maintainers/nemishkor)[@nemishkor](https://github.com/nemishkor)

---

Top Contributors

[![othillo](https://avatars.githubusercontent.com/u/2786663?v=4)](https://github.com/othillo "othillo (39 commits)")[![wjzijderveld](https://avatars.githubusercontent.com/u/450201?v=4)](https://github.com/wjzijderveld "wjzijderveld (25 commits)")[![asm89](https://avatars.githubusercontent.com/u/657357?v=4)](https://github.com/asm89 "asm89 (9 commits)")[![fritsjanb](https://avatars.githubusercontent.com/u/1194777?v=4)](https://github.com/fritsjanb "fritsjanb (4 commits)")[![ricbra](https://avatars.githubusercontent.com/u/872886?v=4)](https://github.com/ricbra "ricbra (3 commits)")[![krizon](https://avatars.githubusercontent.com/u/880695?v=4)](https://github.com/krizon "krizon (2 commits)")[![erkhembayar-gantulga](https://avatars.githubusercontent.com/u/205824?v=4)](https://github.com/erkhembayar-gantulga "erkhembayar-gantulga (2 commits)")[![fadoe](https://avatars.githubusercontent.com/u/1300722?v=4)](https://github.com/fadoe "fadoe (2 commits)")[![aaa2000](https://avatars.githubusercontent.com/u/163941?v=4)](https://github.com/aaa2000 "aaa2000 (2 commits)")[![nemishkor](https://avatars.githubusercontent.com/u/12599510?v=4)](https://github.com/nemishkor "nemishkor (1 commits)")[![eriwin](https://avatars.githubusercontent.com/u/3142606?v=4)](https://github.com/eriwin "eriwin (1 commits)")[![roverwolf](https://avatars.githubusercontent.com/u/210211?v=4)](https://github.com/roverwolf "roverwolf (1 commits)")[![samnela](https://avatars.githubusercontent.com/u/1852108?v=4)](https://github.com/samnela "samnela (1 commits)")[![Spea](https://avatars.githubusercontent.com/u/495017?v=4)](https://github.com/Spea "Spea (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/nemishkor-toggle-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[friendsofsymfony/http-cache-bundle

Set path based HTTP cache headers and send invalidation requests to your HTTP cache

43813.2M47](/packages/friendsofsymfony-http-cache-bundle)[sulu/sulu

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

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)

PHPackages © 2026

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