Organizing the directory structure of my DDD web application?

I started looking away from the usual MVC method for building my web applications and looked at Domain Driven Design - DDD.

Only having Models , now I have Collections , Entities , DataMappers and Repositories in my application for work. A complete separation and modularity for sure, but now my directory structure is nothing more than a complete mess!

As I have never worked with a DDD application in the past, I have little idea on how to organize my file structure.

Below is a suitable directory structure?
Note. I use PHP5, but I find this question close to language agnostic.

 /application /common /libraries /helpers /temp /cache /domain /collections /entities /datamappers /repositories /ui /controllers /view 
+6
source share
1 answer

I would think that it makes sense, but it will divide your modules into the level at which they are, and not what they do. For example, in this structure, if you want authentication and print modules, you have something like this:

  /common /helpers /Authentication /AuthenticationService.php /Printing /PrintingService.php /domain /entities /Authentication /Identity.php /Printing /Printer.php /datamappers /Authentication /IdentityDataMap.php /Printing /PrinterDataMap.php 

Having worked in such a system, I can say that on the one hand it is very difficult to maintain the boundaries between the modules due to meshing, simply because people work in layers and think of layers as β€œall together.” From an organizational point of view, I I don’t really like to have three root directories open for working with a specific module, we organize projects in directories to make it easier for us, not the compiler.

If I did this again, I would separate some things by layer, for example, user interface code on one level and business code on another, and then modulo. I believe it is more of a hybrid, but perhaps better for it.

  /domain /Printing /entities /datamappers /repositories /Auth /entities /datamappers /repositories /ui /controllers /view 
+5
source

Source: https://habr.com/ru/post/894670/


All Articles