Ryan Weaver
Contributed by Ryan Weaver in #36655

Some Symfony components (e.g. Cache, Lock, Messenger, etc.) can store their contents in databases using Doctrine ORM. This requires some manual setup to work. For example, to store sessions in the database you must create the table that stores the information.

We're big fans of automation, so we decided to automate all this in Symfony 5.1. The idea is to implement some event subscribers that listen to advanced Doctrine events (e.g. Events::onSchemaCreateTable from Doctrine DBAL and ToolEvents::postGenerateSchema from Doctrine ORM) and inject the SQL code required to create the database tables needed by each component.

These automatic database tables are generated only when you really need them. Consider for example the Messenger component. If you configure a Doctrine transport and run the make:migration command, the database is created. Otherwise, nothing will change in your database table. The same happens when using PdoAdapter from Cache component, PdoStore from Lock component, etc.

Symfony Docs will be updated soon to reflect this automation and simplify the setup required in some components.

Published in #Living on the edge