Ind*_*ial 6 php domain-driven-design directory-structure
我已经开始关注创建我的Web应用程序的正常MVC方式,并看看了Domain Driven Design - DDD.
从具有Models独自一人,我现在有Collections,Entities,DataMappers和Repositories在我的应用程序一起工作.完全分离和模块化肯定,但现在我的目录结构只是一个完整的混乱!
由于我以前从未使用过DDD应用程序,因此我对如何组织文件结构几乎一无所知.
以下是一个合适的目录结构?
注意:我使用的是PHP5,但我认为这个问题与语言无关.
/application
/common
/libraries
/helpers
/temp
/cache
/domain
/collections
/entities
/datamappers
/repositories
/ui
/controllers
/view
Run Code Online (Sandbox Code Playgroud)
我认为这是有道理的,但是,这会将你的模块分成它们所处的层,而不是它们的作用.例如,在这种结构中,如果你想要一个身份验证和打印模块,你可能会有这样的事情:
/common
/helpers
/Authentication
/AuthenticationService.php
/Printing
/PrintingService.php
/domain
/entities
/Authentication
/Identity.php
/Printing
/Printer.php
/datamappers
/Authentication
/IdentityDataMap.php
/Printing
/PrinterDataMap.php
Run Code Online (Sandbox Code Playgroud)
在这样的系统中工作,我可以说,一方面,很难保持模块之间的界限不相互啮合,只是因为人类在层中工作,并将层视为"全部在一起".仅从组织的角度来看,我真的不希望打开三个根级目录来使用特定模块.我们将项目组织到目录中以使我们更容易处理,而不是编译器.
如果我再次这样做,我会在一个层面上分开一些东西,比如在一个层面上分析UI代码,在另一个层面上分离业务代码,然后按照那个模块分开.我认为更多的混合动力,但也许更好.
/domain
/Printing
/entities
/datamappers
/repositories
/Auth
/entities
/datamappers
/repositories
/ui
/controllers
/view
Run Code Online (Sandbox Code Playgroud)