Update README.md

This commit is contained in:
tλeUniC
2022-04-06 19:07:00 +02:00
committed by GitHub
parent 01217c7c35
commit 2b6f0e524e

View File

@@ -3,7 +3,7 @@
<img src="http://gitmood.app/assets/images/cheeper.svg" width="150" alt="cheeper logo">
</a>
<br>
CQRS by Example Book code repository
DDD CQRS by Example Book code repository
</h1>
<h4 align="center">Cheeper is a Twitter clone used in the book <a href="http://leanpub.com/cqrs-by-example/">CQRS By Example</a> as a reference implementation.</h4>
@@ -15,9 +15,16 @@
<img src="https://img.shields.io/static/v1?label=Built+with&message=%E2%9D%A4%EF%B8%8F&color=FDE0D9" alt="Built with love" />
</p>
## How to run the application
## Table of contents
### Requirements
* Code structure
* Running the application
### Code Structure
### Running the application
#### Requirements
* Just install [docker](http://docs.docker.com/get-docker/).
* If you want to run PHP locally and leave docker for just external services (mysql, redis, elastic and rabbitmq):
@@ -25,7 +32,7 @@
* Needed PHP extensions: pdo_mysql, mysqli, amqp.
* Make sure to install [Symfony CLI](http://symfony.com/download).
### 🐳 Full Docker
#### 🐳 Full Docker
This code can run fully on docker. In order to do so just run
@@ -41,7 +48,7 @@ And to stop all services just run
Cheeper starts totally as a blank application. There is no Author, Cheeps, Follows, etc. Let's see what happens with the existing Projections when
#### Follower Counters Query
##### Follower Counters Query
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/followers-counter
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/followers-counter
@@ -54,7 +61,7 @@ Expected output
"data": "Author \"a64a52cc-3ee9-4a15-918b-099e18b43119\" does not exist"
}
#### Author Timeline
##### Author Timeline
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/timeline
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/timeline
@@ -68,7 +75,7 @@ Expected output
}
...
#### Adding Authors
##### Adding Authors
Cheeper is configured so signing up new Authors is a synchronous operations. This mean that once the HTTP request made to the Cheeper API is finished, the Author will be in the database without having to perform any other action. As soon the API receives the request, the SignUpCommand is created and delegated to the Command Bus. The Command Bus will check the routing configurations and it will pass the Command to the SignUpCommandHandler that will perform all the actions required to sign up a new Author.
@@ -86,7 +93,7 @@ Expected output
The response to the HTTP request and the Authors in the database are not the only outcome generated. In RabbitMQ, there are store multiple events of type `NewAuthorSigned`. Those Domain Events are waiting to be handled. In order to do so, they will have to be consumed. Until not getting consumed, the Follower Counters Query will still return a 404 HTTP Status Code.
#### Consuming Events
##### Consuming Events
php bin/console messenger:consume events_async
@@ -106,7 +113,7 @@ There is one `NewAuthorSigned` event to handle for each new Author signed in. Th
Now, that all the Domain Events are processed, and their corresponding Projections are calculated, the queries to check how many followers - an Author has - are not empty anymore.
#### Follower Counters Query
##### Follower Counters Query
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/followers-counter
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/followers-counter
@@ -126,7 +133,7 @@ Expected output
}
...
#### Author Timeline
##### Author Timeline
http --json --body http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/timeline
http --json --body http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/timeline
@@ -138,7 +145,7 @@ Expected output
"cheeps": []
}
#### Following other Authors
##### Following other Authors
Following an Author is a Command that is defined as asynchronous. This means that once the request to the Cheeper API is done, the Command will wait to be processed by a worker. The initial HTTP request to the API returns really fast, but the changes in the database will not be done until the Command is processed.
@@ -149,7 +156,7 @@ Following an Author is a Command that is defined as asynchronous. This means tha
php bin/console messenger:consume events_async
#### Follower Counters Query
##### Follower Counters Query
http --json http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/followers-counter
http --json http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/followers-counter
@@ -168,13 +175,13 @@ Expected output
}
}
#### Posting Cheeps
##### Posting Cheeps
http --json --body POST http://127.0.0.1:8000/chapter7/cheep cheep_id="28bc90bd-2dfb-4b71-962f-81f02b0b3149" author_id="a64a52cc-3ee9-4a15-918b-099e18b43119" message="Hello world, this is Bob"
http --json --body POST http://127.0.0.1:8000/chapter7/cheep cheep_id="04efc3af-59a3-4695-803f-d37166c3af56" author_id="1fd7d739-2ad7-41a8-8c18-565603e3733f" message="Hello world, this is Alice"
http --json --body POST http://127.0.0.1:8000/chapter7/cheep cheep_id="8a5539e6-3be2-4fa7-906e-179efcfca46b" author_id="1da1366f-b066-4514-9b29-7346df41e371" message="Hello world, this is Charlie"
#### Author Timeline
##### Author Timeline
http --json http://127.0.0.1:8000/chapter7/author/a64a52cc-3ee9-4a15-918b-099e18b43119/timeline
http --json http://127.0.0.1:8000/chapter7/author/1fd7d739-2ad7-41a8-8c18-565603e3733f/timeline