- Symfony Flex is a Composer plugin that modifies the behavior of the requirements, update, and remove commands.
- Symfony Flex is the new way to install and manage packages
- Auto-configuration via recipes
- Flex works for Symfony 3.3 or higher, from Symfony 4.0 Flex is used as an option by default.
II. How does Flex work?
When installing new package by execute “composer require”, the app will request to the Symfony Flex server first:
- If there’s no information about that package, the Flex server returns nothing and the package installation follows the usual procedure based on Composer;
- If there’s a special information about that package, Flex returns it in a file called a “recipe” and the application uses it to decide which package to install and which automated tasks to run after the installation.
III. Symfony Flex recipes
Symfony Flex recipes manage all third-party packages to integrate into Symfony application.
– Maintained by Symfony Core Team
– Can use alias
– Anyone can contribute
– Cannot use alias
Recipes are defined in “mainfest.json” file.
Example mainfest.json of swiftmailer package
Install new package
Result: we can see Flex auto-configuration, we don’t need to look or edit bundles.php.
Thus, Symfony Flex is so convenient. It helps you improve your productivity so much and create Symfony applications, from the most simple micro-style projects to the more complex ones with dozens of dependencies. We strongly recommend to upgrade your existing applications to it.
Do you have project in mind? Do not hesitate to contact us! 😉