Example Component using Domain-driven Design and Hexagonal Architecture principles and recommandations based on what have learned by reading DDD related books, watching YouTube videos and conferences about DDD and hexagonal architecture specifically applied to PHP and also some developer focused podcasts on this topic.
This repo is more or less like a folder structure to ease the use of "DDD" and "Hexagonal Architecture" also known as "Ports and Adapters" applied to Joomla component. In other words, I'm constantly learning every day new stuff, mainly about tech and here, I share what I've learned about Domain-driven Design applied to Joomla custom component development
There are mainly 3 layers :
- 3 - Infrastructure : Code specific to your favorite CMS (Drupal,Joomla,TYPO3,WordPress,etc...)
- 2 - Application : Code where you put Interfaces of Repository pattern, Clock Service to alter time
- 1 - Domain : Code of your Value Objects, your Entities and your Business Rules specific to your Domain
I would like to add 2 more layers which are "horizontal layers" that can be used cross layers on all other layers
- B - Libraries : PHP Libraries for example from packagist.org
- A - Internal : PHP Core (or any language used by your component. It's the foundation on everything else depends)
Basically a layer MAY depend on itself and/or lower layers
You want to be able to publish your content simultanuously on Drupal, Joomla, TYPO3 and WordPress because that's what your VIP clients use. So you hire a team of 6 developers aware of DDD best practices. One of them used Joomla and stumbled on this article. How would these principles apply in real life for your agency?
-
3: Infrastructure
- Drupal
- Drupal specific code implementing Application layer code and/or using Domain layer code
- Joomla
- Joomla specific code implementing Application layer code and/or using Domain layer code
- TYPO3
- TYPO3 specific code implementing Application layer code and/or using Domain layer code
- WordPress
- WordPress specific code implementing Application layer code and/or using Domain layer code
- Your favorite CMS and/or Framework here
- CMS and/or Framework specific code implementing Application layer code and/or using Domain layer code
- Drupal
-
2: Application:
- VIPClient
- VIPClientRepositoryInterface
- VIPClientRepositoryServiceInterface
- ...
- ClockInterface (Could use PSR-20 from Libraries "horizontal" layer)
- VIPClient
-
1: Domain
- BusinessRules
- DeployArticlesToVIPClientsOnly
- ...
- Common
- AbstractValueObject
- Name
- Company
- Role
- ...
- VIPClient
- Reward
- LifetimeCustomerValue
- ...
- ...
- BusinessRules
-
B : Libraries layer
- composer packages, npm packages, ...
-
A : Internal layer
- PHP Core (the language), Javascript (the language), etc...
There are no Tests folder in this repo with all kinds of tests: Isolation Tests, Integration Tests, Smoke Tests, Benchmark Tests, Security Tests, etc...
Because I wanted in this repo to focus on folder structure of how to use DDD when coding your own custom Joomla component.