[英]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. 代码很长,因此下面是要求的顶级检查列表。
Create a doctrine entity manager configuration instance ( Doctrine\\ORM\\Configuration
). 创建一个理论实体管理器配置实例(
Doctrine\\ORM\\Configuration
)。
$config = new Doctrine\\ORM\\Configuration();
Populate the configuration with the required data (metadata driver, cache config etc). 用所需的数据(元数据驱动程序,缓存配置等)填充配置。 Doctrine's documentation is a good reference here to what would be required ( http://docs.doctrine-project.org/en/latest/reference/configuration.html )
在这里,Doctrine的文档很好地参考了所需的内容( http://docs.doctrine-project.org/en/latest/reference/configuration.html )
Example here uses the Annotation driver: 此处的示例使用注释驱动程序:
$driver = new Driver\AnnotationDriver(
new Annotations\CachedReader(new Annotations\AnnotationReader(), new Cache\ArrayCache()),
$entityDirs
);
$config->setMetadataDriverImpl($driver);
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.