Zend Framework: Zend Tool and Doctrine 2 Integration Component Proposal
| Proposed Component Name | Zend Tool and Doctrine 2 Integration |
|---|---|
| Developer Notes | http://framework.zend.com/wiki/display/ZFDEV/Zend Tool and Doctrine 2 Integration |
| Proposers | Benjamin Eberlei |
| Zend Liaison | TBD |
| Revision | 1.0 - 23th November 2009 (wiki revision: 2) |
Table of Contents
1. Overview
This Proposal aims to integrate Zend Framework and Doctrine 2 via Zend Tool.
Doctrine 2 CLI commands like Schema Tool should be integrated into the Zend
Tool Project context. This allows to setup the Doctrine 2 from withing
Zend Application within Zend Tool.
2. References
3. Component Requirements, Constraints, and Acceptance Criteria
- This component MUST use Doctrine 2 Resource for Zend_Application
- This resource SHOULD be usable with both Modular and non-modular MVC applications.
- This component MUST integrate all Doctrine 2 CLI Tasks
- This component SHOULD offer further providers that help the integration of ZF and Doctrine 2
- This component SHOULD make use of other Zend components for this goal.
- This component SHOULD optionally support prototyping of forms
- This component SHOULD optionally support prototyping of entity base classes.
- This component MAY support Zend_Test and Doctrine integration.
4. Dependencies on Other Framework Components
- Zend_Application
- Zend_Tool_Framework
- Zend_Tool_Project
- Zend_Form
- Zend_CodeGenerator
5. Theory of Operation
You can configure your Doctrine 2 EntityManager instance with the following maximum options.
All the options are Doctrine 2 specific and can be looked up in the documentation. The EntityManagerFactory
instance delays the creation of the entity manager as long as possible. This is
recommended when some of your actions don't require an active database connection. A use would look like:
For modularity you can retrieve the entitymanagerfactory (not the entitymanager)
from within any init method and add further metadata paths:
The Zend Tool integration will use the configured Zend Application resource
to configure Doctrine 2 for the use with Schema Tool or other CLI tasks.
With a configured Doctrine2 resource you will be able to issue the following commands:
Commands will all make heavy use of --verbose and --pretend flags.
Using the optional generation tasks we can create:
1. Forms
Abstract Form that has elements for all entity properties.
2. Models
Abstract Model that has getter/setter and protected properties for all entity fields.
(Won't work with Annotations Metadata).
3. Repository/Criteria
This is maybe for a next version. Use the configured entity repository class option
of Doctrine 2 and generate abstract Repository/Criteria pattern objects.
Code-Generation will always only create abstract classes in the schema
- EntityNameFormAbstract
- EntityNameAbstract
- EntityNameRepositoryAbstract
- EntityNameCriteriaAbstract
The developer then has to build the implementations of these abstract classes
himself. This way re-creation of the abstract classes will not destroy your
self-written code.
A question is how the transformation between entities and form data population
sould look like.
6. Milestones / Tasks
- Milestone 1: Community Review
- Milestone 2: Prototype
- Milestone 3: Zend Acceptance
- Milestone 4: Completion & Documentation
7. Class Index
- Zend_Doctrine2_Application_Resource_Entitymanagerfactory
- Zend_Doctrine2_Tool_Provider_Dc2Project
- Zend_Doctrine2_Tool_Provider_Dc2Build
- Zend_Doctrine2_Tool_Provider_Dc2Query
- Zend_Doctrine2_Tool_Provider_Dc2Cache
- Zend_Doctrine2_Tool_Build
- Zend_Doctrine2_Tool_Query
- Zend_Doctrine2_Tool_Cache
- Zend_Doctrine2_CodeGenerator_Model
- Zend_Doctrine2_CodeGenerator_Form
- Zend_Doctrine2_CodeGenerator_Repository
- Zend_Doctrine2_FormAbstract
- Zend_Doctrine2_Form_EntityTransformer
- Zend_Doctrine2_Form_TransformValidator
3 Comments
comments.show.hideOct 20, 2010
Julian Pustkuchen
Doctrine 2 integration in Zend Framework would be so great in general!
I think this would be a push in the right direction.
Nov 03, 2010
Jurian Sluiman
Why is it required to add metadata paths for every module? The modules are loaded automatically because of a Bootstrap.php file in the module directory, so why isn't it possible to do some magic with the autodetect in mind?
Feb 06, 2011
Dolf Schimmel (Freeaqingme)
Archiving this proposal, feel free to recover it when you want to work on it again. For more details see this email.