2022-09-05 22:33:20 +02:00
2022-09-05 22:29:43 +02:00
2022-08-30 15:59:06 +02:00
2022-06-07 17:49:06 +02:00
2022-09-05 20:19:56 +02:00
2022-07-26 17:06:09 +02:00
2022-09-05 20:19:56 +02:00
2021-11-05 19:56:41 +01:00
2022-08-30 22:45:41 +02:00
CI
2022-08-23 09:57:52 +02:00
2022-08-20 11:09:22 +02:00
CI
2022-08-23 09:57:52 +02:00
2022-09-05 22:33:20 +02:00
2022-08-23 15:16:34 +02:00
2022-09-05 08:49:17 +02:00
2022-08-31 16:24:48 +02:00

cheeper logo
Hexagonal Architecture + DDD + CQRS Workshop

CI status PHP Version Symfony Version Built with love

Cheeper is a Twitter clone used in the book CQRS By Example as a reference implementation. In this branch you will find an starter code for a Hexagonal Architecture, DDD (tactical patterns) and CQRS (Command query responsibility segregation) workshop.

Code Structure

This repository follows a typical PHP application layout: All the code lives in the src folder and classes map 1:1 with the file where they live, following the PSR-4 standard for class autoloading.

The App namespace

This namespace contains all the classes that are specific to the delivery mechanism. In this case the delivery mechanism is the Symfony framework following the recommended structure.

The Cheeper namespace

src/Cheeper
├── Application 👉 Contains Application Services
├── DomainModel 👉 Contains all the domain model classes
└── Infrastructure 👉 Contains all the domain-related infrastructure

Running the application

Requirements

  • Docker 👉 To run all services in your computer without installing all the dependencies.
  • Docker Compose 👉 To orchestrate the services. If you're on Mac or Windows and you already have Docker Desktop installed, you already have Docker Compose installed. If you're on Linux, you can check out installation here.

Booting up 🚀

The first thing you should do is to have a fresh copy of the code. To do so just clone the repository and switch to the workshop branch.

git clone https://github.com/dddshelf/cheeper-ddd-cqrs-example.git
git checkout -b workshop

Then, in order to get environment set up properly, you should have a .env.local file with all the correct values 👇

cp .env.docker.dist .env.local

As the code runs fully on docker, several make targets have been carefully prepared in order to make the interaction with the code as easy and smooth as possible. To start all the services just run 👇

make start

The first time booting the project you will need to install dependencies. To install them run

make deps

This make target, runs docker compose, and ensures all services are up and running. Next, once all the services have been started, we must make sure the database is created, database migrations are executed successfully and fixtures are loaded properly. To do so, just run

make refresh-fixtures

Finally to stop all services just run

make stop

Now you're ready to go with the workshop! 🚀

Accessing the application

From here you can access to the Cheeper API documentation

http://127.0.0.1:8000/api/docs

Running tests

This code is covered by a suite of unit & functional tests and a mutation coverage score of 100% on the Cheeper\Application namespace. To run the tests 👇

make unit-tests # 👉 Runs the unit test suite
make functional-tests # 👉 Runs the functional test suite
make mutation-tests # 👉 Runs the mutation tests

Static analysis

This code is statically analysed by psalm, the coding style is inspected by php-cs-fixer, and the layer dependencies are monitored using deptrack. In order to run the whole static analysys 👇

make local-ci

Or if you prefer to run one by one

make unit-tests
make psalm
make check-cs
make deptrack
Languages
PHP 97.8%
Makefile 1.3%
Twig 0.7%
Dockerfile 0.2%