In a nutshell
Symfony Flex is a Composer plugin that hooks into the Composer installation process. When it detects that a package is being installed which it recognizes and for which it has a recipe (some setup code), it executes the recipe.
Symfony flex makes it easier to install and configure packages in one step. Most flex recipes create a configure file at
Symfony 6 projects have Symfony Flex installed by default. But if you don’t have it installed for whatever reason, run:
composer require symfony/flex
What is a Flex alias and recipe?
symfony/flex installed, when you run something like:
composer require twig
Once it has resolved the alias, it will execute the corresponding recipe. A recipe is any code that a library executes to automatically configure itself – usually by adding and modifying files. Recipes make it easy to quickly install and configure packages.
For example, when the
twig recipe runs, it adds a bunch of configuration files (e.g.,
config/packages/test/twig.yaml) and some directories and files (e.g.,