我正在使用Zend Framework创建一个Web应用程序。基于多个推荐,我选择将Doctrine作为我的RDBM系统。
;---------------------------------------------------
; DOCTRINE CONFIGURATION
;---------------------------------------------------
resources.entityManager.connection.driver = "pdo_mysql"
resources.entityManager.connection.host = "localhost"
resources.entityManager.connection.dbname = "private"
resources.entityManager.connection.user = "private"
resources.entityManager.connection.password = "private"
resources.entityManager.connection.entities = APPLICATION_PATH "/models"
resources.entityManager.connection.proxies.location = APPLICATION_PATH "/models/Proxies"
resources.entityManager.connection.proxies.ns = "Proxies"
; According to Doctrine manual, this should be true for
; development, and false for production
resources.entityManager.connection.proxies.generate = true
上面是我的Zend应用程序配置中的Doctrine配置。一切都很顺利,但我想提前了解如何手动生成代理而不使用CLI,因为几个原因。首先,Doctrine 2.0文档提到自动生成代理会导致性能问题。其次,我仍然没有弄清楚如何使用Doctrine CLI,特别是我已经将项目开发转移到了没有命令提示符访问权限的共享服务器。 我一直通过创建类来手动生成Doctrine实体,那么如何手动生成Doctrine代理?
$config = new \Doctrine\ORM\Configuration; $config->setMetadataCacheImpl(self::getCache()); $config->setMetadataDriverImpl(new \qweb\driver\DoctrineYml( QWEB_MODULE )); $config->setEntityNamespaces(array('base')); $config->setProxyDir(DOCTRINE_PROXIES); $config->setProxyNamespace('proxy'); $connection = \Doctrine\DBAL\DriverManager::getConnection(self::loadYml(QWEB_CONFIG.DIRECTORY_SEPARATOR.'databases.yml')); $em = \Doctrine\ORM\EntityManager::create($connection, $config);
- El'