简体   繁体   English

您能告诉我Zend Framework Project + Doctrine 2的任何相关文件结构吗?

[英]Can you show me any relevant file structure for a Zend Framework Project + Doctrine 2?

I successed to integrate Doctrine 2 and Zend Framework using a Doctrine2 Application Resource and it works great, cli and web, but I couldn't find any informations on how structure my models. 我成功地使用Doctrine2应用程序资源将Doctrine 2和Zend Framework集成在一起,并且可以很好地在cli和Web上运行,但是我找不到有关如何构造模型的任何信息。

Right now, here is my workflow: 现在,这是我的工作流程:

  1. I write my entities in models/Entities using Annotation Driver 我使用注释驱动程序在模型/实体中编写实体
  2. I generate entities with php bin/doctrine orm:schema-tools:create This part overrides my Entities with public setters and getters 我用php bin/doctrine orm:schema-tools:create生成实体这一部分用公共设置器和获取器覆盖我的实体

But I'm struggling here. 但是我在这里苦苦挣扎。

I'm not sure on how Entities should be used. 我不确定应如何使用实体。

should it looks like this : 它应该像这样:

application/
- models/
-- Entities/
--- Product.php
--- Category.php
-- Proxies/
--- Product.php
--- Category.php
-- Repositories/
--- Product.php
--- Category.php

Is it correct or Am I totally wrong? 是对的还是我完全错了?

By the way, when are used both Proxies & Repositories ? 顺便说一下,何时同时使用代理和存储库? I can't find relevant documentation about them. 我找不到有关它们的相关文档。

If you know where I can find an actual Doctrine 2 project, or better an actual Zend Framework + Doctrine 2 Project it'll be great. 如果您知道在哪里可以找到实际的Doctrine 2项目,或者更好的是实际的Zend Framework + Doctrine 2项目,那就太好了。

Thanks for your help. 谢谢你的帮助。

Doctrine 2 generated your Domain Objects and Repositories, it is not your Domain Model. 教义2生成了您的域对象和存储库,它不是您的域模型。 You can perfectly create your Entities in library folder and them implement your Model classes inside models directory of your ZF application. 您可以在library文件夹中完美创建实体,它们可以在ZF应用程序的models目录中实现Model类。

Usually Models contain DO's validation, since DO's are extremely simple and should not contain complex logic. 通常,模型包含DO的验证,因为DO非常简单,并且不应包含复杂的逻辑。 Repositories hold the data manipulation, but it should not include business logic. 存储库可进行数据操作,但不应包含业务逻辑。

Cheers, 干杯,

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM