21 Feb 2019

feedSymfony Blog

New in Symfony Flex 1.2

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

Alex Rock

Contributed by
Alex Rock
in #439.

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

Nicolas Grekas

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

Edi Modrić

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

Jules Pietri

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.*"
    }
}

Be trained by Symfony experts - 2019-02-25 Berlin - 2019-02-25 Berlin - 2019-02-25 Clichy

21 Feb 2019 11:45am GMT

20 Feb 2019

feedSymfony Blog

New in Symfony 4.3: Form improvements

Added a Twig function to get the parent form

Christian Flothmann

Contributed by
Christian Flothmann
in #28812.

In Symfony 4.3 we added a Twig function called parent_form() which returns the parent form view or null if the form view already is the root form. Using this function should be preferred over accessing the parent form using form.parent. The latter way will produce different results for example when a child form is named parent.

Allow including HTML contents in help messages

Mathieu Piot

Contributed by
Mathieu Piot
in #29861.

The contents of the help message that can be defined for form fields are escaped by default to prevent security issues. If your help messages contain HTML elements (e.g. links to other pages) and you know they are safe to render "as is", set to true the new help_html option added in Symfony 4.3:

1
2
3
4
$builder->add('zip_code', null, [
    'help' => '<a target="_blank" href="...">Look up your ZIP code.</a>',
    'help_html' => true,
]);

Configure the input format of DateType and DateTimeType

Thomas Calvet

Contributed by
Thomas Calvet
in #29887.

In Symfony 4.3 we added a new input_format option to DateType and DateTimeType. If the input option is set to string, this option specifies the format of the date, which must be a valid PHP date format.

1
2
3
4
5
6
7
use Symfony\Component\Form\Extension\Core\Type\DateTimeType;

$builder->add('startsAt', DateTimeType::class, [
    // ...,
    'input' => 'string',
    'input_format' => 'm-d H:i',
]);

Be trained by Symfony experts - 2019-02-25 Berlin - 2019-02-25 Berlin - 2019-02-25 Clichy

20 Feb 2019 12:10pm GMT

19 Feb 2019

feedSymfony Blog

The final schedule for SymfonyLive Paris 2019 is out!

Coucou from Paris

The complete schedule for SymfonyLive Paris 2019 is online. Check out the last selected talks and speakers for the conference.


Le SymfonyLive Paris approche, rendez-vous les 28 et 29 mars 2019 à la Cité Internationale Universitaire de Paris.

Nous sommes ravis d'annoncer les derniers sujets sélectionnés au SymfonyLive Paris 2019 ! Nous avons pris le temps d'étudier toutes les propositions de sujet reçues lors du CFP pour le SymfonyLive Paris 2019 et nous remercions une nouvelle fois toutes les personnes qui ont soumis un sujet. Découvrez qui sont les derniers speakers retenus et les sujets qu'ils partageront avec vous durant la conférence :

Serez-vous là ? Prenez vite vos billets avant que le prix n'augmente, l'inscription à la conférence au tarif normal à 289€ est disponible jusqu'au 4 mars !

Vous souhaitez également assister aux formations ? Toutes nos formations sont éligibles au Fafiec, contactez-nous via le support pour votre inscription ! Sinon réservez votre combo formations-conférence directement en ligne. L'inscription aux formations concerne les 2 jours de formation des 26 et 27 mars, vous devez choisir une formation par jour au choix parmi :

Rendez-vous fin mars à Paris ou la semaine prochaine, le 1er mars, au SymfonyLive Lille ! A bientôt !


Be trained by Symfony experts - 2019-02-25 Berlin - 2019-02-25 Berlin - 2019-02-25 Clichy

19 Feb 2019 12:13pm GMT