I'm integrating doctrine with Zend Framework. I've hit an error thrown from cli. It seems Zend_Application_Bootstrap_Bootstrap does not have a require_once for Zend_Application_Bootstrap_BootstrapAbstract. Has anyone hit this?
my cli-config.php
<?php
$classLoader = new \Doctrine\Common\ClassLoader('App', __DIR__ . "/../application/models");
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Cms', __DIR__ . "/../applic开发者_运维技巧ation/modules/cms-modules/models");
$classLoader->register();
$classLoader = new \Doctrine\Common\ClassLoader('Proxies', __DIR__ . "/../application/models");
$classLoader->register();
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache);
$driverImpl = $config->newDefaultAnnotationDriver(array(
__DIR__."/../application/models/App",
__DIR__."/../application/modules/cms-modules/models/Cms"
));
$config->setMetadataDriverImpl($driverImpl);
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
// Database connection information
$connectionOptions = array(
'driver' => 'pdo_mysql',
'dbname' => 'bella',
'user' => 'username',
'password' => 'password',
'unix_socket' => '/Applications/MAMP/tmp/mysql/mysql.sock'
);
$em = \Doctrine\ORM\EntityManager::create($connectionOptions, $config);
$helperSet = new \Symfony\Component\Console\Helper\HelperSet( array(
'db' => new \Doctrine\DBAL\Tools\Console\Helper\ConnectionHelper($em->getConnection()),
'em' => new \Doctrine\ORM\Tools\Console\Helper\EntityManagerHelper($em)
));
Bootstrap class should extends the Bootstrap Abstract class.
class Bootstrap extends Zend_Application_Module_Bootstrap {
//.....
}
Zend_Application does not use require_once. It is one of the first packages in ZF 1.* that requires the Zend Autoloader.
Yep replacing the doctrine class loader with Zend's auto loader did the trick. I had to add the path to the namespaces directly to the php path using set_include_path. Is there a nicer way to do this? I see Doctrine's class loader allows you to specify both the path and namespace. Thanks for your help beberlei and Alex
精彩评论