Skip to content

Commit e283678

Browse files
author
julien
committed
doc(README): add notice to install and use bundle
1 parent 8760e3b commit e283678

File tree

4 files changed

+74
-16
lines changed

4 files changed

+74
-16
lines changed

README.md

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,55 @@
11
# TwcBusBundle
22

3-
Provide simple way to implement Message Bus concept in Symfony 4
3+
Provide simple way to implement Message Bus concept in Symfony 4.
4+
5+
## Before start
6+
7+
Thank's [@lilobase](https://twitter.com/Lilobase) for you excellent talk at [PHP TOUR 2018](https://afup.org/talks/2628-cqrs-fonctionnel-event-sourcing-domain-driven-design).
8+
9+
Thank's [@matGiWeb](https://twitter.com/matGiWeb) for you approach with [cqrs-skeleton](https://github.com/magi-web/cqrs-skeleton)
10+
11+
## Remember
12+
13+
CQRS (Command Query Responsibility Segregation) it's an architectural pattern that aims to separate the **writing** (Command) and **reading** (Query).
14+
15+
16+
## Installation
17+
18+
```
19+
20+
composer require twc/bus-bundle
21+
22+
```
23+
24+
## How to use ?
25+
26+
You only have to implement the desired interface
27+
28+
### About commands
29+
30+
| topic | Interface |
31+
|--------|-----------|
32+
| Command | Twc\BusBundle\Command\Interfaces\Command |
33+
| CommandHandler | Twc\BusBundle\Command\Interfaces\CommandHandler |
34+
| Middleware | Twc\BusBundle\Command\Interfaces\CommandBusMiddleware |
35+
36+
### About Events
37+
38+
| topic | Interface |
39+
|--------|-----------|
40+
| Event | Twc\BusBundle\Event\Interfaces\Event |
41+
| EventHandler | Twc\BusBundle\Event\Interfaces\EventHandler |
42+
43+
### About Queries
44+
45+
| topic | Interface |
46+
|--------|-----------|
47+
| Query | Twc\BusBundle\Query\Interfaces\Query |
48+
| QueryHandler | Twc\BusBundle\Event\Interfaces\QueryHandler |
49+
50+
That's all !
51+
CommandBus, EventBus, QueryBus will do the work, thank's Dependencies Injection and autowiring in symfony.
52+
53+
54+
55+

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"description": "Provide simple way to implement Message Bus concept in Symfony 4",
44
"keywords": [
55
"symfony",
6+
"symfony 4",
67
"command bus",
78
"Domain events",
89
"cqrs",

src/DependencyInjection/TwcBusExtension.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
use Symfony\Component\DependencyInjection\ContainerBuilder;
77
use Symfony\Component\DependencyInjection\Extension\Extension;
88
use Symfony\Component\DependencyInjection\Loader\YamlFileLoader;
9+
use Twc\BusBundle\Command\Interfaces\CommandHandler;
10+
use Twc\BusBundle\Event\Interfaces\EventHandler;
11+
use Twc\BusBundle\Query\Interfaces\QueryHandler;
912

1013
class TwcBusExtension extends Extension
1114
{
@@ -15,7 +18,15 @@ public function load(array $configs, ContainerBuilder $container)
1518
$container,
1619
new FileLocator(__DIR__ . '/../Resources/config')
1720
);
18-
21+
$container->registerForAutoconfiguration(CommandHandler::class)
22+
->addTag('twc_bus.command.handler');
23+
24+
$container->registerForAutoconfiguration(EventHandler::class)
25+
->addTag('twc_bus.event.handler');
26+
27+
$container->registerForAutoconfiguration(QueryHandler::class)
28+
->addTag('twc_bus.query.handler');
29+
1930
$loader->load('services.yaml');
2031
}
2132

src/Resources/config/services.yaml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,20 @@
11
services:
2-
_instanceof:
3-
Twc\BusBundle\Command\Interfaces\CommandHandler:
4-
tags: ['command.handler']
5-
6-
Twc\BusBundle\Event\Interfaces\EventHandler:
7-
tags: ['event.handler']
8-
9-
Twc\BusBundle\Query\Interfaces\QueryHandler:
10-
tags: ['query.handler']
112

123
Twc\BusBundle\Event\EventBusDispatcher:
13-
arguments: [!tagged 'event.handler']
4+
arguments: [!tagged 'twc_bus.event.handler']
5+
6+
Twc\BusBundle\Command\CommandBusFactory: ~
147

158
Twc\BusBundle\Command\CommandBus:
169
factory: 'Twc\BusBundle\Command\CommandBusFactory:build'
1710
arguments:
18-
- !tagged 'command.handler'
19-
- !tagged 'command.middleware'
11+
- !tagged 'twc_bus.command.handler'
12+
- !tagged 'twc_bus.command.middleware'
2013
lazy: true
2114

2215
Twc\BusBundle\Query\QueryBusDispatcher:
23-
arguments: [!tagged 'query.handler']
16+
arguments: [!tagged 'twc_bus.query.handler']
2417

2518
Twc\BusBundle\Event\EventBusDispatcherMiddleware:
26-
tags: ['command.middleware']
19+
arguments: ['@Twc\BusBundle\Event\EventBusDispatcher']
20+
tags: ['twc_bus.command.middleware']

0 commit comments

Comments
 (0)