A Symfony project made with DDD, CQRS and Hexagonal Architecture

Overview

Symfony Blog DDD + CQRS + Hexagonal Architecture

A Symfony blog project made with CQRS, Hexagonal Architecture and DDD

Docker integration

This project has been created using the Symfony Docker repository.

Configuration

This projects use the LexikJWTAuthenticationBundle to provide JWT authentication so you need to:

Generate the SSL Keys:

$ php bin/console lexik:jwt:generate-keypair

Deploy

  1. If not already done, install Docker Compose
  2. In docker-compose.override.yml choose between dev or prod environment
  3. Run docker-compose build --pull --no-cache to build fresh images
  4. Run docker-compose up (the logs will be displayed in the current shell)
  5. Open https://localhost in your favorite web browser and accept the auto-generated TLS certificate
  6. Run docker-compose down --remove-orphans to stop the Docker containers.
  7. If you work on linux and cannot edit some of the project files right after the first installation, you can run docker-compose run --rm php chown -R $(id -u):$ (id -g) . to set yourself as owner of the project files that were created by the docker container.

Usage

This is an API project with authentication based in JWT token.

You can first register your user and then make a login request to get the JWT token. Then you can do the authenticated requests including this token in an Authorization header with Bearer format.

Comments

I have started from the symfony-ddd-cqrs-hexagonal-skeleton project (also implemented by myself) as a base that already provides me with some functions that I need, such as CQRS with Symfony Messenger, exception handling, serialization, validation.... .

I use named constructors in some classes to prevent Symfony include them as services and due to semantic reasons.

I use adr pattern in Controllers to preserve the Single Responsability principle in them.

I'm only testing Domain Entities behaviour, sorry, I'm not very experienced in testing for now.

Why only API is implemented? I think web side should not be in the same project. It's better to separate backend and frontend into two different projects. For now I'm not interested in frontend so this project is gonna be only Api.

Why Controller is creating the identifiers? Follow CQRS standard implies return no result in commands, but it's necessary return domain objects id's as the response in POST creation requests. So, I think is acceptable create a not-domain identifier in the controller, and let the command turn it into an appropiate Domain Id.

Why update methods are empty in ORM repositories? A repository should differentiate between creating and updating, regardless of the specific implementation (ORM, ODM, Api, Redis Client...). In the case of Doctrine, no action is required to update an entity, because it is already done when the flush method is called by the DoctrineTransactionMiddleware. However, I want to keep the update action in the repository, so if in the future it has to be changed to something else that doesn't work with Doctrine (API repository, for example), update calls are already done.

Why are you including a trailing slash in all your routes? The standard is to remove the trailing slash of all routes but recently I have experimented problems in other projects with Safari and the solution was add this trailing slash in my routes to evade Symfony redirection. This is fixed in last Safari updates but I am currently adding this slash to prevents old Safari clients can't request correctly.

Why are you using specification pattern with plain values? Standard Specification pattern uses the Domain entity (DE) to validate invariants, however, this is impossible to apply to validate DE invariants because I am following the Always-valid domain model and I can't pass an invalid DE to the specification. I could simply use if sentences in the DE, but I need to do the same validations as input validations in the Application Layer, so... I decided to use a little different Specifications to validate plain values. Also, I added a validation context (only used in Application Layer) to return valid error messages to the Presentation Layer.

You might also like...
PHP Lightweight Message Bus supporting CQRS.
PHP Lightweight Message Bus supporting CQRS.

Prooph Service Bus PHP 7.1+ lightweight message bus supporting CQRS and Micro Services Important This library will receive support until December 31,

A DDD microservice did in laravel, to test infrastructure

A DDD microservice did in laravel, to test infrastructure

Test and enforce architectural rules in your Laravel applications. Keep your app's architecture clean and consistent!
Test and enforce architectural rules in your Laravel applications. Keep your app's architecture clean and consistent!

Laravel Arkitect Laravel Arkitect lets you test and enforce your architectural rules in your Laravel applications, and it's a PHPArkitect wrapper for

The game is implemented as an example of scalable and high load architecture combined with modern software development practices
The game is implemented as an example of scalable and high load architecture combined with modern software development practices

Crossword game The game is implemented as an example of scalable and high load architecture combined with modern software development practices Exampl

my personal example of Laravel clean architecture

what is this repo about Clean Architect Laravel ###run we assume docker desktop is up and running open up a terminal cd project directory run "cp .env

Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...
Detect flaws in your architecture, before they drag you down into the depths of dependency hell ...

Detect flaws in your architecture before they drag you down into the depths of dependency hell ... What it does System Requirements Installation Phive

The Lucid Architecture for Scalable Laravel Applications.
The Lucid Architecture for Scalable Laravel Applications.

Website: https://lucidarch.dev Documentation: https://docs.lucidarch.dev Social: we share updates & interesting content from the web Twitter: @lucid_a

A research raw data repository for researchers of Arba Minch University built using Codeigniter which follows MVC architecture. The front-end is build using Bootstrap.

Arba Minch University Dataset Repository This system is a research dataset repository for Arba Minch University researchers and is build using Codeign

Roach-example-project - Example project to demonstrate how to use RoachPHP in a Laravel project.

Example repository to illustrate how to use roach-php/laravel in a Laravel app. Check app/Spiders/FussballdatenSpider.php for an example spider that c

Owner
null
🐘 🎯 Hexagonal Architecture, DDD & CQRS in PHP

?? ?? Hexagonal Architecture, DDD & CQRS in PHP Example of a PHP application using Domain-Driven Design (DDD) and Command Query Responsibility Segrega

CodelyTV 2.5k Jan 6, 2023
Dockerise Symfony Application (Symfony 6 + Clean Architecture+ DDD+ CQRS + Docker + Xdebug + PHPUnit + Doctrine ORM + JWT Auth + Static analysis)

Symfony Dockerise Symfony Application Install Docker Install Docker Compose Docker PHP & Nginx Create Symfony Application Debugging Install Xdebug Con

null 48 Jan 5, 2023
Clean Architecture, DDD and CQRS using Symfony 6

Task manager system using Clean Architecture, DDD and CQRS. Environment setup Install Docker Clone the project: git clone https://github.com/k0t9i/Tas

null 3 Sep 5, 2022
Ecotone Framework is Service Bus Implementation. It enables message driven architecture and DDD, CQRS, Event Sourcing PHP

This is Read Only Repository To contribute make use of Ecotone-Dev repository. Ecotone is Service Bus Implementation, which enables message driven arc

EcotoneFramework 308 Dec 29, 2022
Enraged Xenomorph - DDD/CQRS Symfony Application Boilerplate

Enraged Xenomorph - DDD/CQRS Symfony Application Boilerplate This project is very opinionated attempt to compile a bit of experience, few good practic

Gniewomir Świechowski 1 Jan 10, 2022
Orkestra is a library of infrastructure and architecture helpers for creating CQRS applications

Orkestra Orkestra is an opinionated framework with a plethora of recommendations on architectural design that we use internally at Morebec to develop

Morébec 2 Aug 18, 2021
POC d'un projet Clean Architecture + DDD

Proof Of Concept - Clean Architecture & DDD Installation Dans un premier temps, cloner le repository : git clone https://github.com/TBoileau/rse cd rs

Thomas Boileau 11 Sep 3, 2022
FFCMS 3 version core MVC architecture. Build-on use with ffcms main architecture builder.

FFCMS 3 version core MVC architecture. Build-on use with ffcms main architecture builder.

FFCMS 0 Feb 25, 2022
Demo project for the API Platform / DDD Workshop

Workshop DDD x API Platform This is a demo project used for the DDD x API Platform Workshop by @chalasr & @mtarld from @coopTilleuls. Checkout git clo

Les-Tilleuls.coop 34 Dec 16, 2022
Small convention based CQRS library for PHP

LiteCQRS for PHP Small naming-convention based CQRS library for PHP (loosely based on LiteCQRS for C#) that relies on the MessageBus, Command, EventSo

Benjamin Eberlei 560 Nov 20, 2022