douzhang5984 2013-03-30 11:19
浏览 47

PHP中的域驱动设计架构

In a PHP DDD application with a folder structure like this:

app/
    views/
    controllers/
    domain/
        models/ ( orm generated )           
        services/
        factories/  

what would the following classes represent(from a DDD terminology point of view) and what would be the recommanded location for them.

Dictionary ( basic functionality: checks if a word is valid ) HtmlValidator ( basic functionality: checks if a string is a valid html ) UserCollection ( basic functionality: operations on a collection of users )
  • 写回答

2条回答 默认 最新

  • duanaoreng9355 2013-03-30 12:36
    关注

    This doesn't look like a DDD application.

    In particular, ORM generated models are not domain models. This is a good thing, if your application core value is in data and you just need to handle CRUD operations.

    In a DDD application models comes from the language of the domain expert, that is a person that know that business that your application target as it's his own job but does not know anything about tech.

    If your domain expert talks about Dictionaries and UserCollection (quite strange, btw) such classes are actually models. HtmlValidator, almost by definition, is not a business term.

    I suggest you to avoid using DDD tecniques if the value of your application comes from technological components. Use DDD only for applications that handle very complex business rules.

    edit
    Most of times domain models worth (at laest) a separate module. In PHP I would suggest you to bundle it in (at least) a separate package. However using the MVC pattern does not imply to use DDD: you can use MVC for a data driven application, and that's fine. In such case I would put in models only ORM generated classes. In such a scenario I would put all that classes in a controllers/lib folder.

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度