{"id":19074933,"url":"https://github.com/mguinea/php-ddd-microservice-example","last_synced_at":"2025-04-29T16:45:55.210Z","repository":{"id":230447310,"uuid":"402313861","full_name":"mguinea/php-ddd-microservice-example","owner":"mguinea","description":"Microservice in Hexagonal Architecture + DDD + CQRS in PHP using Lumen and Symfony","archived":false,"fork":false,"pushed_at":"2021-11-05T06:59:29.000Z","size":173,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-18T19:41:32.625Z","etag":null,"topics":["best-practices","composer","cqrs","ddd","docker","docker-compose","hexagonal","lumen","makefile","microservice","php","solid","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mguinea.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-09-02T06:25:47.000Z","updated_at":"2024-04-24T09:56:01.000Z","dependencies_parsed_at":"2024-03-29T19:50:17.504Z","dependency_job_id":"119f2022-0a6d-4d56-8bb2-1cf28f5f8740","html_url":"https://github.com/mguinea/php-ddd-microservice-example","commit_stats":null,"previous_names":["mguinea/php-ddd-microservice-example"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Fphp-ddd-microservice-example","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Fphp-ddd-microservice-example/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Fphp-ddd-microservice-example/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mguinea%2Fphp-ddd-microservice-example/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mguinea","download_url":"https://codeload.github.com/mguinea/php-ddd-microservice-example/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251543641,"owners_count":21606494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["best-practices","composer","cqrs","ddd","docker","docker-compose","hexagonal","lumen","makefile","microservice","php","solid","symfony"],"created_at":"2024-11-09T01:52:49.858Z","updated_at":"2025-04-29T16:45:55.151Z","avatar_url":"https://github.com/mguinea.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003e\n  PHP Microservice example using DDD, Hexagonal and best practices\n\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://lumen.laravel.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Lumen-8-FF2D20.svg?style=flat-square\u0026logo=lumen\" alt=\"Lumen 8\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://symfony.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/Symfony-5-000000.svg?style=flat-square\u0026logo=symfony\" alt=\"Symfony 5\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.php.net/\"\u003e\u003cimg src=\"https://img.shields.io/badge/PHP-8-777BB4.svg?style=flat-square\u0026logo=php\" alt=\"PHP\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.jetbrains.com/es-es/phpstorm/?ref=steemhunt\"\u003e\u003cimg src=\"https://img.shields.io/badge/PhpStorm-2021-000000.svg?style=flat-square\u0026logo=phpstorm\" alt=\"PhpStorm\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.docker.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/docker-3-2496ED.svg?style=flat-square\u0026logo=docker\" alt=\"Docker\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.mysql.com/\"\u003e\u003cimg src=\"https://img.shields.io/badge/mysql-5.7-4479A1.svg?style=flat-square\u0026logo=mysql\" alt=\"MySql\"/\u003e\u003c/a\u003e\n    \u003ca href=\"https://www.sqlite.org/index.html\"\u003e\u003cimg src=\"https://img.shields.io/badge/sqlite-3-003B57.svg?style=flat-square\u0026logo=sqlite\" alt=\"SQLite\"/\u003e\u003c/a\u003e\n    \u003ca href=\"#\"\u003e\u003cimg src=\"https://img.shields.io/badge/github_actions-2088FF.svg?style=flat-square\u0026logo=github-actions\" alt=\"Github Actions\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  This is a repo containing a \u003cstrong\u003ePHP application using Domain-Driven Design (DDD) and Command Query Responsibility Segregation\n  (CQRS) principles\u003c/strong\u003e.\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  It's a basic implementation of a User - Role manager. There is a version implemented using Lumen framework and another one using Symfony framework.\n  \u003cbr /\u003e\n  Both shares the same \u003ccode\u003edomain\u003c/code\u003e logics implemented in the \u003ccode\u003esrc\u003c/code\u003e folder.\n  \u003cbr /\u003e\n  \u003cbr /\u003e\n  \u003ca href=\"https://github.com/mguinea/php-ddd-microservice-example/issues\"\u003eReport a bug\u003c/a\u003e\n  ·\n  \u003ca href=\"https://github.com/mguinea/php-ddd-microservice-example/issues\"\u003eRequest a feature\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://github.com/mguinea/php-ddd-microservice-example/actions\"\u003e\u003cimg src=\"https://github.com/mguinea/php-ddd-microservice-example/workflows/CI/badge.svg\" alt=\"CI pipeline status\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Installation\n\n### Requirements\n- [Install Docker](https://www.docker.com/get-started)\n\n### Environment\n\n- Clone this project: `git clone https://github.com/mguinea/php-ddd-microservice-example php-ddd-microservice-example`\n- Move to the project folder: `cd php-ddd-microservice-example`\n- Create a local environment file `cp .env.example .env`\n- Change (if required) ports and any other environment variables in `.env` file\n\n### Execution\n\nInstall all the dependencies and bring up the project with Docker executing: `make install`\n\nThen you'll have 2 apps available (an api made using Lumen and the same one made using Symfony):\n1. Lumen API: http://localhost:8180/lumen/api/v1/health-check\n2. Symfony API: http://localhost:8180/symfony/api/v1/health-check\n\n### Tests\n\nInstall the dependencies if you haven't done it previously: `make composer-install`\n\nExecute all test suites: `make tests`\n\n## Monitoring\n\nTODO\n\n## Project structure and explanation\n\n### Bounded contexts\n\n`src` folder contains the bounded context responsible for the management of users and roles and their relations.\n\n### Architecture and Structure\n\nThis repository follows the Hexagonal Architecture pattern. Also, it's structured using modules. With this, we can see that the current structure of the Bounded Context is:\n\n```scala\n$ tree -L 2 src\n\nsrc\n├── Application\n│   ├── Role\n│   └── User\n├── Domain\n│   ├── Role\n│   ├── Shared\n│   └── User\n└── Infrastructure\n    ├── Role\n    ├── Shared\n    └── User\n```\n\n#### Repositories\n\n##### Repository pattern\n\nOur repositories try to be as simple as possible usually only containing basic CRUD methods (delete, find, save and search).\nIf we need some query with more filters we use the Specification pattern also known as Criteria pattern. So we add a `searchByCriteria` method.\n\n##### Implementations\n\nThere is an implementation using `Eloquent` for `Lumen` and another one made by using `PDO` for `Symfony`\n\n#### CQRS\n\nWe are using `symfony messenger` to implement buses for Lumen and Symfony implementations.\n\n#### My conventions\n\nThere are some opinionated resolutions / approaches in this project.\n\n##### Generic methods (CRUDs)\n\n- `get` retrieve an entity. If not found, throws an exception.\n- `find` retrieve an entity. If not found, return null.\n- `delete` delete an entity. If not found, throws an exception.\n- `create` create an entity. If found, throw an exception.\n- `update` update an entity. If not found, throws an exception.\n- `search` retrieve a collection of entities by criteria. If nothing found, returns an empty collection.\n- `listing` retrieve a collection of entities with no criteria. If nothing found, returns an empty collection.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmguinea%2Fphp-ddd-microservice-example","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmguinea%2Fphp-ddd-microservice-example","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmguinea%2Fphp-ddd-microservice-example/lists"}