Qandidate\Toggle bundle for symfony

Qandidate\Toggle bundle for symfony

Quandidate toggle bundle provides toggling for the particulare features by simple configuartions in symfony, By using this bundle you can easily hide/display some features in your symfony application. Please check Quandidate/Toggle on Github.

How to install

composer require qandidate/toggle-bundle ~0.1

Add the bundle to your Kernel.

$bundles = array(
    new Qandidate\Bundle\ToggleBundle\QandidateToggleBundle()

How to Configure

   persistence: in_memory|redis
   context_factory: null|
   redis_namespace: toggle_%kernel.environment%
   redis_client: null|

How to use

/* Your service.yml */
    class: YourClass
    arguments: ['qandidate.toggle.manager', 'qandidate.toggle.user_context_factory']

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

public function controllerAction(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),

How to use in Twig via toggle twig extension

{% if feature_is_active('comments') %}
    {{ "comments feature is active" }}
{% endif %}