How Recipes Work

Video not working?

It looks like your browser may not support the H264 codec. If you're using Linux, try a different browser or try installing the gstreamer0.10-ffmpeg gstreamer0.10-plugins-good packages.

Thanks! This saves us from needing to use Flash or encode videos in multiple formats. And that let's us get back to making more videos :). But as always, please feel free to message us.

Where do these Flex recipes lives? They live... in the cloud. More specifically, if you look back at https://flex.symfony.com, you can click to view the Recipe for any of the packages. This goes to... interesting: a GitHub repository called symfony/recipes.

Go to the homepage of this repository. This is the central repository for recipes, organized by the name of the package... and then each package can have different recipes for different versions. Our recipe lives in sensiolabs/security-checker/4.0.

Looking at the Source of a Recipe

Every recipe has at least this manifest.json file, which describes all of the "things" it should do. This copy-from-recipe says that the contents of the config/ directory in the recipe should be copied into our project. This is why a config/packages/security_checker.yaml file was added to our app.

Back in the manifest, the composer-scripts section tells Flex to add this line to our composer.json file... and aliases define... well... the aliases that should map to this package.

There are a few other things that a recipe can do, but this is the basic idea.

So... all Symfony recipes live in this one repository. Hmm, actually, that's not true: all Symfony recipes lives in this repository or in another one called recipes-contrib. There's no difference between these, except that quality control is higher on recipes merged into the main repository.

Using Composer to View Recipes

Another way you can see details about the recipes is via Composer itself. Run:

composer recipes

These are the 7 recipes that have been installed into our app. And if we run:

composer recipes sensiolabs/security-checker

We can see more details, like the URL to the recipe and files it copied into our app.

Anyways, the recipe system is going to be our best friend: allowing our app to start tiny, but grow automatically when we install new packages.

Removing a Package & Recipe

Oh, and if you decide that you want to remove a package, its recipe will be uninstalled. Check it out:

composer remove sec-checker

That - of course - will remove the package... but it also "unconfigured" the recipe. When we run:

git status

It's clean! It reverted the change in composer.json and removed the config file.

67 lines composer.json
{
... lines 2 - 3
"require": {
"php": "^7.2.5",
"ext-ctype": "*",
"ext-iconv": "*",
"sensio/framework-extra-bundle": "^5.5",
"symfony/console": "5.0.*",
"symfony/dotenv": "5.0.*",
"symfony/flex": "^1.3.1",
"symfony/framework-bundle": "5.0.*",
"symfony/yaml": "5.0.*"
},
... lines 15 - 44
"scripts": {
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
... lines 50 - 55
},
... lines 57 - 65
}

Next: let's install Twig - Symfony's templating engine - so we can create HTML templates. The Twig recipe is going to make this so easy.

Leave a comment!

What PHP libraries does this tutorial use?

// composer.json
{
    "require": {
        "php": "^7.2.5",
        "ext-ctype": "*",
        "ext-iconv": "*",
        "easycorp/easy-log-handler": "^1.0.7", // v1.0.9
        "sensio/framework-extra-bundle": "^5.5", // v5.5.3
        "symfony/asset": "5.0.*", // v5.0.5
        "symfony/console": "5.0.*", // v5.0.4
        "symfony/debug-bundle": "5.0.*", // v5.0.4
        "symfony/dotenv": "5.0.*", // v5.0.4
        "symfony/flex": "^1.3.1", // v1.9.10
        "symfony/framework-bundle": "5.0.*", // v5.0.4
        "symfony/monolog-bundle": "^3.0", // v3.5.0
        "symfony/profiler-pack": "*", // v1.0.4
        "symfony/twig-pack": "^1.0", // v1.0.0
        "symfony/var-dumper": "5.0.*", // v5.0.4
        "symfony/webpack-encore-bundle": "^1.7", // v1.7.3
        "symfony/yaml": "5.0.*" // v5.0.4
    },
    "require-dev": {
        "symfony/profiler-pack": "^1.0" // v1.0.4
    }
}