Skip to content

Commit 6dcd9dc

Browse files
committed
Update readme
1 parent b868a81 commit 6dcd9dc

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

Diff for: README.md

+63
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,66 @@
11
#Wheels
22

33
Wheels is a PHP implementation of the Command Bus pattern for DDD.
4+
5+
[![Build Status](https://travis-ci.org/maximecolin/wheels.svg)](https://travis-ci.org/maximecolin/wheels)
6+
7+
##Disclaimer
8+
9+
This is a very basic and simple implementation. It has to grow up :)
10+
11+
##Installation
12+
13+
```
14+
composer require maximecolin/wheels
15+
```
16+
17+
##Purpose
18+
19+
The aim of the command bus pattern is to isolate your domain code in atomic, testable and reusable classes and to execute them through a dedicated service.
20+
21+
##Usage
22+
23+
Create a command class to handle data you need. Attributes can be set on contruct, fill through a form, set by other services, ...
24+
25+
```
26+
class CreateArticleCommand implements CommandInterface
27+
{
28+
public $title;
29+
public $content;
30+
31+
public function __construct($title, $content)
32+
{
33+
$this->title = $title;
34+
$this->content = $content;
35+
}
36+
}
37+
```
38+
39+
Create an handler which will process your command.
40+
41+
```
42+
class CreateCommandHandler implements CommandHandlerInterface
43+
{
44+
public function handle(CommandInterface $command)
45+
{
46+
// Place here you domain code which create an article ...
47+
}
48+
}
49+
```
50+
51+
52+
53+
```
54+
// Usualy, have a service to get the bus
55+
$bus = new CommandBus();
56+
$bus->addResolver(new ClassNameResolver());
57+
58+
$command = new CreateArticleCommand('My article name', 'My article content');
59+
60+
$bus->execute($command);
61+
```
62+
63+
##Comming soon
64+
65+
Event sourcing integration.
66+

0 commit comments

Comments
 (0)