phpsymfonyeventscqrsprooph

Configuration prooph in Symfony DI Container


I configured all prooph service buses with event source and event store.

But it's one thing what make me confused. I must call: $eventPublisher = $this->container->get('event_publisher'); in my CommandBusFactory to glue event emitter and event bus together for dispatching domain event (from Aggregate Root) throught bus to projector. Without this my projections are not called.

My services: link

Can someone with experience in Symfony DI (Extension and CompilerPass) help me with it?


Solution

  • The event publisher is not part of your dependency chain. That's the reason why it is not initialized by symfony DI. The event publisher is an event store plugin and you have correctly configured symfony DI to call the method attachToEventStore but this is not done automatically but only when you request the service from the DI.

    To solve the problem you need a factory for the event store that takes a list of plugins and calls the attachToEventStore method on each plugin. The prooph/event-store-symfony-bundle contains such a factory