symfonysymfony4symfony-flex

How do Symfony Flex recipes know what packages to install?


I am trying to understand how Symfony recipes know what packages to install along the way.

Reading the source code, it seems to me that when I run

composer require twig

the composer, having flex as a plugin,

  1. looks for an alias called twig
  2. sees that it is registered for the recipe symfony/twig-pack
  3. downloads the recipe and reads its manifest.json
  4. executes all the actions defined in manifest.json, like creating extra files or appending stuff to files

But nowhere do I see in the manifest.json to install the actual package symfony/twig-pack.

Is it just implicit that all recipes have to share their name with the package they are installing and that this is the way how composer knows what package to install?

I.e. a developer can not just create a recipe invented_company/nonexisting_package that just adds a few files here and appends a few lines there, but not actually corresponds to a package on packagist?


Solution

  • There is a description of the creation of recipes.

    It says

    Recipes must be stored on their own repositories, outside of your Composer package repository. They must follow the vendor/package/version/ directory structure, where version is the minimum version supported by the recipe.

    https://github.com/symfony/recipes/blob/master/README.rst