Feature Flag and Strategy pattern with the Symfony framework

Smaine Milianni
5 min readMar 7, 2023

πŸ“– The feature flag is a method to update and change the behavior of an application without changing the code.

I did a video about this topic (πŸŽ₯ pardon my French πŸ₯–).

Most of the time the feature flag is stored in a table, with a simple boolean, and when you want to check if the toggle is enabled you fetch the good row based on the feature name and check if it’s enabled or not, but what if we want to store our feature flag in a different place or we want to rely it on a specific period or we want to check dynamically based on a current context.

⚑️ In this article, we will use the magic of Symfony πŸͺ„ to make a Feature Flag extendable as you wantπŸ‘Œ.

πŸ’‘ For my use case, I want to have the possibility of having different resolvers to fetch my feature flag.

Let’s write some User Stories to make things more clear πŸ˜…πŸ–Š

  • As a Developer, my feature flag can be in a table (in a database).
  • As a Developer, my feature flag can be configured with the Symfony parameters.
  • As a Developer, my feature flag can be enabled during a specific period
  • As a Developer, my feature flag can be enabled with A/B testing algorithm

--

--

Smaine Milianni

Fullstack Developer- certified Symfony 4,5 and certified AWS Solution Architect - Freelancer - Remote Worker