Implementing Feature Toggles in Symfony

Gabriel Anhaia
Dev Warlocks
Published in
3 min readJul 22, 2023

--

Feature toggles, also known as feature flags, are a powerful technique that allows developers to enable or disable features in a running application without deploying new code. This mechanism provides much flexibility in managing your features, allowing you to perform canary releases, A/B testing, and gradual rollouts. In this post, we’ll take a look at how to implement feature toggles in a Symfony application.

There are a couple of ways to implement feature toggles in Symfony, but we will use the FlagceptionBundlerobust feature flag bundle for Symfony that allows you to define and manage feature flags.

Installation

First, install the bundle via Composer:

composer require bestit/flagception-bundle

Configuration

After installation, you'll need to configure your feature flags. You can do this in the config/packages/flagception.yaml file:

flagception:
features:
'feature_one': true
'feature_two': false

--

--

Gabriel Anhaia
Dev Warlocks

Software Engineer (Billie GmbH), Freelancer, and Author. Germany/Brazil. Book Design Patterns em PHP: https://goo.gl/NNDZqe