Magento 2 Experten — Hyvä Theme, Tailwind CSS & SEO aus einer Hand ›

Composer and Symfony Flex in Depth

Composer and Symfony Flex in Depth

~12 Min. Lesezeit Zuletzt aktualisiert am August 8, 2026

To wrap up block 1, let's understand HOW Symfony packages get installed – especially Symfony Flex, the Composer plugin that drives the "magic" automatic configuration behind composer require.

composer require in detail

composer require symfony/mailer

A simple Composer command, but with Symfony Flex, MORE happens than with a normal PHP library: Flex recognizes that symfony/mailer is a known Symfony package and automatically applies an associated "recipe".

What is a recipe?

A recipe is a small set of instructions maintained in the public symfony/recipes repository that automatically:

  • Creates default configuration files under config/packages/.
  • Adds needed environment variables to .env.
  • Creates new directories where needed.

After composer require symfony/mailer, you'll automatically find a new config/packages/mailer.yaml AND a new MAILER_DSN line in .env – WITHOUT having created either manually.

Tracing what Flex changed

cat symfony.lock | grep -A2 "symfony/mailer"

symfony.lock (analogous to composer.lock, but Flex-specific) records WHICH recipe version was applied for EACH package – useful for later tracing what got auto-generated during an install.

Recipes we use over the course of this training

PackageWhat the recipe sets up automatically
symfony/orm-packSets up Doctrine ORM (block 4): config/packages/doctrine.yaml, DATABASE_URL in .env.
symfony/security-bundleSets up security (block 5): config/packages/security.yaml.
symfony/mailerSets up the mailer (chapter 38): config/packages/mailer.yaml, MAILER_DSN in .env.
symfony/test-packSets up PHPUnit for testing (block 7): phpunit.dist.xml, tests/bootstrap.php.

Understanding composer.json

composer.json
{
    "require": {
        "php": ">=8.2",
        "symfony/framework-bundle": "7.2.*",
        "symfony/twig-bundle": "7.2.*"
    },
    "require-dev": {
        "symfony/maker-bundle": "^1.60"
    }
}

7.2.* is Symfony's recommended version format: allows PATCH updates (7.2.1, 7.2.2, ...) automatically, but prevents unwanted jumps to 7.3, which might contain breaking changes.

symfony/maker-bundle: code generators

Already included in require-dev – this bundle provides bin/console make:... commands we'll encounter repeatedly from block 2 on (make:controller, make:entity, make:form, ...):

php bin/console list make
# shows all available make: commands

Tipp: --no-dev installs packages WITHOUT the require-dev dependencies – EXACTLY what we use in chapter 48 for production-ready deployments, since maker-bundle and friends aren't needed there and would only add unnecessary disk space and potential attack surface.

With that, block 1 (foundations & first project) is complete! Block 2 covers routing and controllers – the core that actually turns an HTTP request into code.