I am actually reading a book called "DDD in PHP", to help me understand the Domain Driven Design. So far everything is good, but I struggle to understand how to implement one specific topic without coupling Bounded Contexts: Domain Events
Let's say I have to BCs :
- Payments: Handles generation of invoices, sending them to the customers, etc
- Orders: Handles the creation of orders, their state, etc.
When an Order
is placed, an OrderCreated
Event is dispatched.
The Payments
BC catches this event with a subscriber, and creates the invoice.
The problem is, If I want to perfectly separate both BCs, where should the OrderPlaced
Event live, since it's used by both BCs ? Should it live outside both BCs ? In both of them ? What if I want to deploy the Invoices module as a standalone, without having access to the Orders module, and its OrderPlaced event definition, would it cause some fatal errors ?
Thank you in advance for the answers !