Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

New in Symfony 5.1: Automatic schema updates

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.


Nice one! Thanks!!! ♥️
Good job, really helpful!!!
Good job!

Comments are closed.

To ensure that comments stay relevant, they are closed for old posts.