require_once missing doctrine zend framework

假如想象 提交于 2019-12-25 12:10:03

问题


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__ . "/../application/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)
));

回答1:


Bootstrap class should extends the Bootstrap Abstract class.

class Bootstrap extends Zend_Application_Module_Bootstrap {
   //.....
}



回答2:


Zend_Application does not use require_once. It is one of the first packages in ZF 1.* that requires the Zend Autoloader.




回答3:


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



来源:https://stackoverflow.com/questions/3624206/require-once-missing-doctrine-zend-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!