Giter VIP home page Giter VIP logo

serodas / librarify-php-ddd Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 341 KB

Librarify is a monorepo with Hexagonal Architecture + DDD + CQRS in PHP using Symfony 6 ๐Ÿ˜๐ŸŽฏ This project tries to be a library platform with books, authors, categories, and so on.

PHP 97.37% Dockerfile 0.39% Makefile 1.31% Gherkin 0.82% Shell 0.11%
ddd elasticsearch hexagonal-architecture php-cqrs php-ddd php-rabbitmq rest-api symfony library librarify

librarify-php-ddd's Introduction

๐Ÿ˜๐ŸŽฏ Hexagonal Architecture, DDD & CQRS in PHP

Librarify is a PHP application using Domain-Driven Design (DDD) and Command Query Responsibility Segregation (CQRS) principles keeping the code as simple as possible.

๐Ÿš€ Environment Setup

๐Ÿณ Needed tools

  1. Install Docker
  2. Clone this project: git clone https://github.com/serodas/librarify-php-ddd.git
  3. Move to the project folder: cd librarify-php-ddd

๐Ÿ› ๏ธ Environment configuration

  1. Create a local environment file (cp .env .env.local) if you want to modify any parameter

๐Ÿ”ฅ Application execution

  1. Install all the dependencies and bring up the project with Docker executing: make build
  2. Then you'll have 2 apps available (2 APIs):
    1. Librarify Backend: http://localhost:8030/health-check
    2. Backoffice Backend: http://localhost:8040/health-check
Note: If you are using Rest Client extension in VSCode, you can use the provided requests in the etc/endpoints
folder to test the API endpoints.

โœ… Tests execution

  1. Install the dependencies if you haven't done it previously: make deps
  2. Execute PHPUnit and Behat tests: make test

๐Ÿ‘ฉโ€๐Ÿ’ป Project explanation

This project tries to be a library platform. It's decoupled from any framework, but it has some Symfony implementation.

โ›ฑ๏ธ Bounded Contexts

  • Librarify: Place to look in if you wanna see some code ๐Ÿ™‚. Library platform with books, authors, categories, and so on.

  • Backoffice: Here you will find a projection of books stored in Elasticsearch.

๐ŸŽฏ Hexagonal Architecture

This repository follows the Hexagonal Architecture pattern. Also, it's structured using modules. With this, we can see that the current structure of a Bounded Context is:

$ tree -L 4 src

src
|-- Librarify // Company subdomain / Bounded Context: Features related to one of the company business lines / products
|   `-- Books // Some Module inside the Librarify context
|       |-- Application
|       |   |-- Create // Inside the application layer all is structured by actions
|       |   |   |-- BookCreator.php
|       |   |   |-- CreateBookCommand.php
|       |   |   `-- CreateBookCommandHandler.php
|       |   `-- Find
|       |-- Domain
|       |   |-- Book.php // The Aggregate of the Module
|       |   |-- BookCreatedDomainEvent.php // A Domain Event
|       |   |-- BookDescription.php
|       |   |-- BookNotFound.php
|       |   |-- BookRepository.php // The `Interface` of the repository is inside Domain
|       |   |-- BookScore.php
|       |   `-- BookTitle.php
|       `-- Infrastructure // The infrastructure of our module
|           |-- DependencyInjection
|           `-- Persistence
|               `--DoctrineBookRepository.php // An implementation of the repository
`-- Shared // Shared Kernel: Common infrastructure and domain shared between the different Bounded Contexts
    |-- Domain
    `-- Infrastructure

Repository pattern

Our repositories try to be as simple as possible usually only containing 2 methods search and save. If we need some query with more filters we use the Specification pattern also known as Criteria pattern. So we add a searchByCriteria method.

Command Bus

There is 1 implementations of the command bus.

  1. Sync using the Symfony Message Bus

Query Bus

The Query Bus uses the Symfony Message Bus.

Event Bus

The Event Bus uses the Symfony Message Bus. The MySql Bus uses a MySql+Pulling as a bus. The RabbitMQ Bus uses RabbitMQ C extension.

  • Rabbit Management: :8090 Rabbit

Reference

Based on course DDD in PHP by CodelyTV

librarify-php-ddd's People

Contributors

serodas avatar

Watchers

 avatar

Forkers

c24-darchipov

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.