简体   繁体   English

集成Zend Framework 1和Doctrine 2

[英]Integrate Zend Framework 1 and Doctrine 2

I would like to use Doctrine (v2.4) in my ZendFramework (v1.11) application, which I am starting from scratch. 我想在我的ZendFramework(v1.11)应用程序中使用Doctrine(v2.4),我从头开始。 There are some articles describing such integration, but they seem quite complicated and a little out of date. 有一些文章描述了这种集成,但是它们看起来很复杂并且有些过时。 Is there any fairly simple way to connect ZF1 and Doctrine2? 有没有相当简单的方法来连接ZF1和Doctrine2?

I've implemented this as an application resource (extending \\Zend_Application_Resource_ResourceAbstract ) 我已经将此实现为应用程序资源(扩展\\Zend_Application_Resource_ResourceAbstract

The code is quite long so below is a top level check list of the requirements. 代码很长,因此下面是要求的顶级检查列表。

Example here uses the Annotation driver: 此处的示例使用注释驱动程序:

$driver = new Driver\AnnotationDriver(
  new Annotations\CachedReader(new Annotations\AnnotationReader(), new  Cache\ArrayCache()), 
  $entityDirs
 );
 $config->setMetadataDriverImpl($driver);
  • Lastly pass this new config instance to the static entity manager EntityManager::create 最后,将此新的配置实例传递给静态实体管理器EntityManager::create

EG ( $options here is the database connection info as exampled in the above link) EG( $options这里是上面链接中示例的数据库连接信息)

$entityManager = EntityManager::create($options['database'], $config);

Take a look at my full source, at the very least it will give you a head start: 看看我的完整资料,至少它会为您提供一个良好的开端:

https://github.com/alex-patterson-webdev/Multiverse/blob/master/lib/Multiverse/Application/Resource/Entitymanager.php https://github.com/alex-patterson-webdev/Multiverse/blob/master/lib/Multiverse/Application/Resource/Entitymanager.php

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

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