Hugo Soltys
Hugo Soltys

My name is Hugo, I'm 28 and I'm a Symfony developer since 2013. I love to create websites by myself to learn new technologies or increase my skills.

2019-11-21 - Today Freelance Symfony developer
M6 Web
2018-10-16 - 2019-11-20 Symfony developer
2016-01-01 - 2018-10-15 Symfony developer
IT Room
2014-09-01 - 2015-12-31 Symfony developer
2013-09-01 - 2014-08-31 Student symfony developer
Work with me

Write your own recipes for your Composer packages with Symfony Flex

June 20, 2018 by Hugo - 3557 views - 0 Comments

Warning : Please notice this article is more than 1 year old. Some mechanics may have changed due to the newer versions of the used tools.
Write your own recipes for your Composer packages with Symfony Flex

Symfony recipes allow the automation of Composer packages configuration via the Symfony Flex Composer plugin.

It is pretty useful to avoid boring rituals like writing packages configuration, routes, parameters...

In this article we will learn how to write your own recipes for your private repositories.

Come on, let's do this !

The main disadvantage of the official recipes repository is that you are forced to contribute to add your own recipes but they will be public.

Fortunately, there is a proxy-application for symfony/flex called Symfony Flex Server. This Flex plugin allows you to use your own 3rd party recipes very easily.

How does it works ?

Let's assume that you developed a package called myvendor/mypackage.

If you want to install it in your Symfony project, you will do the following command :

$ composer req myvendor/mypackage

By doing it, Composer will download the source code from your Git repository and then the Flex component will call the API to see if a recipe for your package is available.

It's possible to configure your composer.json to call another endpoint that the official one by adding the following line:

    "extra": {
        "symfony": {
            "id": "01BNAS3890XQPHCYXQ127296J0",
            "allow-contrib": false,
            "endpoint": "",

Unfortunately by doing it you will call exclusively your custom endpoint, and you will no more be able to use the official recipes.

Now I invite you to clone the Symfony Flex Server and launch it (documentation in the file).

The strength of the Symfony Flex Server is it will search for a recipe firstly on the API and then on the Flex Server one.

Two calls are made and the two responses are merged.

So, if you have written a recipe for your package, just place it under the recipes/ directory but respect the vendor/package/version architecture. Once done, run the following command :

$ bin/flex build

You are now able to use Symfony recipes for your own private repositories as much as the official ones.


The Flex Server I'm providing to you is a pull request of the Aurimas Niekis's one.


Thanks for reading,