Javel's notes

TIL; Symfony messenger & doctrine_transaction

Symfony messenger can be configured to use the doctrine_transaction middleware in order to encapsulate all SQL queries performed within command handlers in a single transaction.

As a main consequence, it's no longer necessary to call flush from each handlers, as it will now be performed by the middleware. Dependency injection is therefore lightened, as we don't need to inject the entity manager anymore for that usage.

Sources

© Joris Langlois 2023