我是 symfony 的新手,我有一个与使用 Doctrine 在 Symfony 中实现干净的域驱动设计相关的问题
在 Zend 框架中,我的结构如下
模型文件夹
用户(数据库中的文件夹和表)
Row.php(User 文件夹中的类名 Model_User_Row)
Rowset.php(User 文件夹中的类名 Model_User_Rowset)
Table.php(User 文件夹中的类名 Model_User_Table)
Repository.php(User 文件夹中的类名 Model_User_Repository)
Service.php(User 文件夹中的类名 Model_User_Service)
我希望使用 Doctrine 在 Symfony 中创建类似的结构(我知道 Doctrine 有它自己的方式)
我的问题是 Tool 在 AppBundle 中创建 Entity 文件夹和 Repository 文件夹并将所有内容放入这些文件夹中。
我的愿望是在 Symfony 中进行创作
应用程序包
模型(文件夹)
用户(文件夹)
User.php//User文件夹中的实体
UserRepository.php//User 文件夹中的存储库
我尝试更改以下代码
orm:
auto_generate_proxy_classes: "%kernel.debug%"
naming_strategy: doctrine.orm.naming_strategy.underscore
auto_mapping: false
mappings:
person:
type: annotation
dir: "%kernel.root_dir%/../src/AppBundle/Model/Person"
prefix: AppBundle\Model\Person
alias: AppBundle
is_bundle: false
然后创建新的实体,但没有成功
请指教
最佳答案
我和你有同样的担忧,通常我会采用这种结构
Entity
-- Model (here goes User.php)
-- Repository (here goes UserRepository.php)
Services
-- Domain (my 100% business Logic, 100% covered by tests with mocks)
-- FormBuilder (where I hydrate my formsType by their DTO etc..)
-- ..etc..
因为我使用Entity作为顶级目录,所以唯一需要的配置就是将Entities/Repositories移动到它们的目录并调整注释中的repositoryClass
关于symfony - 使用 Symfony 和 Doctrine 实现领域驱动设计,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36876051/