Zend framework 条令2存储库中的Zend Framework自动加载程序

Zend framework 条令2存储库中的Zend Framework自动加载程序,zend-framework,doctrine-orm,Zend Framework,Doctrine Orm,我在我的项目中使用Zend框架和条令2。除了autoloader不从条令存储库加载Zend类之外,一切都正常 以下是我的Zend autoloader引导程序部分: /** * Register namespace Default_ * @return Zend_Application_Module_Autoloader */ protected function _initAutoload() { $autoloader = new Zend_Application_Module

我在我的项目中使用Zend框架和条令2。除了autoloader不从条令存储库加载Zend类之外,一切都正常

以下是我的Zend autoloader引导程序部分:

/**
 * Register namespace Default_
 * @return Zend_Application_Module_Autoloader
 */
protected function _initAutoload() {
    $autoloader = new Zend_Application_Module_Autoloader(array(
        'namespace' => 'Default_',
        'basePath'  => dirname(__FILE__),
    ));
    return $autoloader;
}
以下是我的原则初始化引导部分:

/**
 * Initialize Doctrine
 * @return Doctrine_Manager
 */
public function _initDoctrine() {
    // include and register Doctrine's class loader
    require_once('Doctrine/Common/ClassLoader.php');
    $classLoader = new \Doctrine\Common\ClassLoader(
        'Doctrine', 
        APPLICATION_PATH . '/../library/'
    );
    $classLoader->register();

    $classLoader = new \Doctrine\Common\ClassLoader(
        'Repositories',
        APPLICATION_PATH . '/../library/Model'
    );
    $classLoader->register();

    // create the Doctrine configuration
    $config = new \Doctrine\ORM\Configuration();

    // setting the cache ( to ArrayCache. Take a look at
    // the Doctrine manual for different options ! )
    $cache = new \Doctrine\Common\Cache\ApcCache;
    $config->setMetadataCacheImpl($cache);
    $config->setQueryCacheImpl($cache);

    // choosing the driver for our database schema
    // we'll use annotations
    $driver = $config->newDefaultAnnotationDriver(
        APPLICATION_PATH . '/../library/Model'
    );
    $config->setMetadataDriverImpl($driver);

    // set the proxy dir and set some options
    $config->setProxyDir(APPLICATION_PATH . '/../library/Model/Proxies');
    $config->setAutoGenerateProxyClasses(true);
    $config->setProxyNamespace('Model\Proxies');

    // now create the entity manager and use the connection
    // settings we defined in our application.ini
    $connectionSettings = $this->getOption('doctrine');
    $conn = array(
        'driver'    => $connectionSettings['conn']['driv'],
        'user'      => $connectionSettings['conn']['user'],
        'password'  => $connectionSettings['conn']['pass'],
        'dbname'    => $connectionSettings['conn']['dbname'],
        'host'      => $connectionSettings['conn']['host']
    );
    $entityManager = \Doctrine\ORM\EntityManager::create($conn, $config);

    // push the entity manager into our registry for later use
    $registry = Zend_Registry::getInstance();
    $registry->entitymanager = $entityManager;

    return $entityManager;
}

我如何解决这个问题?

如果您刚刚开始您的项目,我建议您使用zf2(beta5上一个beta版本如下:)

这是我在我的项目zf2+doctrine 2中使用的教程

您的_initAutoload完全没有必要。 加上

autoloadernamespaces[]  = Default
autoloadernamespaces[]  = Doctrine
对于你的application.ini

我同意不需要_initAutoload(),但我怀疑你在application.ini中需要这个:

autoloaderNamespaces[] = "Doctrine"
autoloaderNamespaces[] = "Model"