How to implement Domain-driven Design and Hexagonal Architecture in your own Joomla custom components
- Details
- Written by: Mr Alexandre J-S William ELISÉ
- Category: API Technical Blog
-
Also available:
Api Adept : Your Website. Augmented.
Don't let technical problems KILL your AMBITIONS...
___ ___ ___ _____ ___ ___
/ /\ / /\ ___ / /\ / /::\ / /\ / /\ ___
/ /::\ / /::\ / /\ / /::\ / /:/\:\ / /:/_ / /::\ / /\
/ /:/\:\ / /:/\:\ / /:/ / /:/\:\ / /:/ \:\ / /:/ /\ / /:/\:\ / /:/
/ /:/~/::\ / /:/~/:/ /__/::\ / /:/~/::\ /__/:/ \__\:| / /:/ /:/_ / /:/~/:/ / /:/
/__/:/ /:/\:\ /__/:/ /:/ \__\/\:\__ /__/:/ /:/\:\ \ \:\ / /:/ /__/:/ /:/ /\ /__/:/ /:/ / /::\
\ \:\/:/__\/ \ \:\/:/ \ \:\/\ \ \:\/:/__\/ \ \:\ /:/ \ \:\/:/ /:/ \ \:\/:/ /__/:/\:\
\ \::/ \ \::/ \__\::/ \ \::/ \ \:\/:/ \ \::/ /:/ \ \::/ \__\/ \:\
\ \:\ \ \:\ /__/:/ \ \:\ \ \::/ \ \:\/:/ \ \:\ \ \:\
\ \:\ \ \:\ \__\/ \ \:\ \__\/ \ \::/ \ \:\ \__\/
\__\/ \__\/ \__\/ \__\/ \__\/
About 8mn to read
HOW IT WORKS:
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)
SUMMARY:
Basically a layer MAY depend on itself and/or lower layers
EXAMPLE USE CASE: You own a Digital Marketing Agency
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
- ...
- DeployArticlesToVIPClientsOnly
- Common
- AbstractValueObject
- Name
- Company
- Role
- ...
- AbstractValueObject
- VIPClient
- Reward
- LifetimeCustomerValue
- ...
- Reward
- ...
- BusinessRules
-
B : Libraries layer
- composer packages, npm packages, ...
-
A : Internal layer
- PHP Core (the language), Javascript (the language), etc...
- Hits: 1150