Provide simple way to implement Message Bus concept in Symfony.
Thank's @lilobase for you excellent talk at PHP TOUR 2018.
Thank's @matGiWeb for you approach with cqrs-skeleton
CQRS (Command Query Responsibility Segregation) it's an architectural pattern that aims to separate the writing (Command) and reading (Query).
symfony powerfull DI with autowire and autoconfigure enable
services:
# default configuration for services in *this* file
_defaults:
autowire: true # Automatically injects dependencies in your services.
autoconfigure: true # Automatically registers your services as commands, event subscribers, etc.
public: false
composer require twc/bus-bundle
If you know CQRS pattern, you only have to implement the desired interface
topic | Interface |
---|---|
Command | Twc\BusBundle\Command\Interfaces\Command |
CommandHandler | Twc\BusBundle\Command\Interfaces\CommandHandler |
Middleware | Twc\BusBundle\Command\Interfaces\CommandBusMiddleware |
topic | Interface |
---|---|
Event | Twc\BusBundle\Event\Interfaces\Event |
EventHandler | Twc\BusBundle\Event\Interfaces\EventHandler |
topic | Interface |
---|---|
Query | Twc\BusBundle\Query\Interfaces\Query |
QueryHandler | Twc\BusBundle\Event\Interfaces\QueryHandler |
topic | Interface |
---|---|
CommandBusDispatcher | Twc\BusBundle\Command\CommandBusDispatcher |
EventBusDispatcher | Twc\BusBundle\Event\EventBusDispatcher |
QueryBusDispatcher | Twc\BusBundle\Query\QueryBusDispatcher |
That's all !
CommandBus, EventBus, QueryBus will do the work, thank's Dependencies Injection and autowiring in symfony.