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
Smaine Milianni

Written by Smaine Milianni

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

Responses (4)