PHP 将Zend Framework 1.10与Doctrine 2集成
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 将Zend Framework 1.10与Doctrine 2集成相关的知识,希望对你有一定的参考价值。
// Bootstrap.php
function _initDoctrine() {
// setup configuration as seen from the sandbox application
// TODO: read configuration from application.ini
$config = new \Doctrine\ORM\Configuration;
$cache = new \Doctrine\Common\Cache\ArrayCache;
$config->setMetadataCacheImpl($cache);
$driverImpl = $config->newDefaultAnnotationDriver('../Application/Entities');
$config->setMetadataDriverImpl($driverImpl);
$config->setQueryCacheImpl($cache);
$config->setProxyDir('../Application/Proxies');
$config->setProxyNamespace('Application\Proxies');
$config->setAutoGenerateProxyClasses(true);
$connectionOptions = array(
'driver' => 'pdo_mysql',
'user' => 'root',
'password' => '',
'dbname' => 'learningzf'
);
// setup entity manager
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
Zend_Registry::set("em", $em);
return $em;
}
// now i can access the entity manager from anywhere thru
$em = Zend_Registry::get('em');
// application.ini
// autoloading Doctrine, Symfony & Application namespace classes. my Doctrine entities are found in library/Application/Entities
autoloaderNamespaces[] = Doctrine
autoloaderNamespaces[] = Symfony
autoloaderNamespaces[] = Application
以上是关于PHP 将Zend Framework 1.10与Doctrine 2集成的主要内容,如果未能解决你的问题,请参考以下文章
Zend Framework 1是否与PHP 7.2兼容?
PHP Zend Framework:将表单重定向回页面用户来自
zend-framework 与 Kohana 与 Symfony [关闭]
PHP Zend Framework:注销后,将用户重定向到他来自的页面
zend framework学习笔记(windows下)
在Zend Framework 2或3中,模块名称可以与类名相同吗?