New in Symfony Flex 1.2
February 21, 2019 • Published by Fabien Potencier
Symfony Flex is a recommended dependency of modern Symfony applications that improves your productivity by automating repetitive and boring tasks, like installing and automatically configuring bundles and other libraries.
Symfony Flex 1.2 has just been released with some useful new features!
Simpler update of recipes
Symfony Recipes define the instructions used by Symfony Flex to install and configure dependencies in your apps. We update recipes continuously to enable new features introduced by libraries or new configuration for a better experience. You don't need to apply these updated recipes to your application. But applying them can sometimes show you new features that you may want to use in your applications.
Symfony Flex already provides a sync-recipes
command to install or reinstall
recipes for the packages installed in an application. However, this command doesn't
execute the recipe again if the recipe was already executed. And so,
the updated version of a recipe is never applied to existing applications.
Symfony Flex 1.2 introduces the --force
option to sync-recipes
to
unconditionally run all the recipes again for all packages. In practice,
it means that Symfony will execute the latest recipe but you will lose any
custom change that you made to the files affected by the recipes.
The solution is to check the changes with git diff
and apply/decline each recipe change:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
$ composer sync-recipes --force
Symfony operations: 10 recipes (8967ada4e2fe4a57735c35d43dd14035)
- Configuring symfony/flex: From github.com/symfony/recipes:master
- Configuring symfony/framework-bundle: From github.com/symfony/recipes:master
- Configuring doctrine/doctrine-bundle: From github.com/symfony/recipes:master
- ...
* Use git diff to inspect the changes.
Not all of the changes will be relevant to your app: you now
need to selectively add or revert them using e.g. a combination
of git add -p and git checkout -p
* Use git checkout . to revert the changes.
New (untracked) files can be inspected using git clean --dry-run
Add the new files you want to keep using git add
then delete the rest using git clean --force
Improved the handling of .env
files
Contributed by
Nicolas Grekas
in #449 and
#501.
If you created your Symfony application after December 2018 or if you have
updated the recipes with sync-recipes --force
recently, you'll see an
important change related to the .env*
config files.
These files are now always loaded, even if you set an APP_ENV=prod
environment variable. The purpose is for the .env
file to define default
values that you can override with real environment values or by creating
a `.env.local` file.
If you want to avoid parsing the .env*
files on every request, Symfony
Flex 1.2 includes a new dump-env
command that compiles the contents of
the .env*
files into a PHP-optimized file called .env.local.php
:
1 2 3
$ composer dump-env prod
Successfully dumped .env files in .env.local.php
That file is then automatically read by the `config/bootstrap.php` file. And
though this command is optional, it may be a good idea to run it during your
deployment workflow to improve the application performance (same as you do with
other commands such as composer dump-autoload -o
).
Other improvements
Auto-installing multiple bundles
Contributed by
Edi Modrić
in #427.
Currently, any package with a symfony-bundle
type in its composer.json
file is enabled as a Symfony bundle when installing it, even if it doesn't have
a Symfony Flex recipe defined for it.
Symfony Flex 1.2 now enables all the bundles found in the autoload configuration
of the composer.json
file, not only the first one.
Conflicting Recipes
Contributed by
Jules Pietri
in #464.
Recipes can now include a conflict
key in their manifests to define the
packages and versions which are not compatible with it. If a conflict is found
when installing a recipe, Symfony Flex displays a message saying that a recipe
installation was skipped and the reason for it:
1 2 3 4 5 6 7
{
"...": "...",
"conflict": {
"symfony/messenger": "^4.2",
"symfony/console": "<3.*"
}
}
Help the Symfony project!
As with any Open-Source project, contributing code or documentation is the most common way to help, but we also have a wide range of sponsoring opportunities.
Comments are closed.
To ensure that comments stay relevant, they are closed for old posts.
Nice! Thanks!
Very usefull features. Force recipes especially and dump env variables. Thanks
Nice work! thanks !!!
Yeah!! just little typo for
conflict
key, should be an object and not an array