CodelyTV / php-ddd-example

🐘🎯 Hexagonal Architecture + DDD + CQRS in PHP using Symfony 7
https://pro.codely.tv/library/ddd-en-php
2.96k stars 1.08k forks source link

Database transaction boundary #356

Closed gabrielanhaia closed 11 months ago

gabrielanhaia commented 11 months ago

Hey there.

This is not 100% a request for a feature, but it might be interesting for some people to know (as for me).

I would like to know where you guys would wrap the database insertion into a transaction.

Looking at the project, my best guess would be here: https://github.com/CodelyTV/php-ddd-example/blob/835bc68b1559a0810168e25d0579d96f4f299deb/src/Shared/Infrastructure/Persistence/Doctrine/DoctrineRepository.php#L20

But I am not 100% sure.

Thanks a lot in advance, and feel free to close this issue if it is the wrong channel

rgomezcasas commented 11 months ago

Wrapping the Use Case or doing a middleware before the command handler. Something like this 🙂

gabrielanhaia commented 11 months ago

Thanks a lot @rgomezcasas