zend-framework - 如何配置 Bisna 以与 Doctrine 2.1 和 Zend Framework 1.11.9 一起使用? [编辑 - 我的错误]

标签 zend-framework doctrine-orm

根据 http://www.zendcasts.com/unit-testing-doctrine-2-entities/2011/02/ 中的说明,我拥有以前版本的 Bisna(7 月 22 日之前),Doctrine 2.0 运行良好。 .

昨天我决定升级到 Doctrine 2.1,并且不得不升级 Bisna,因为它与 Doctrine 2.1 不兼容。
所以我从我的库目录中删除了整个 Doctrine 和 Bisna 目录,引入了每个目录的新版本,在 bootstrap 中添加了 autoload init 方法,并使用相关更改更新了我的 application.ini 文件。

但是,当我尝试访问该应用程序(在 Doctrine 2.0 和以前版本的 Bisna 之前可以正常工作)时,出现以下异常:

Notice: Undefined index: annotationRegistry in /home/doron/workspace/myapp/library/Bisna/Doctrine/Container.php on line 569

进阶资料:
该行(#569)是:
$this->startAnnotationRegistry($config['annotationRegistry']);

当我打印 $config 的内容时,我得到以下信息:
array
  0 => 
    array
      'annotationRegistry' => 
    array
      'annotationFiles' => 
        array
          0 => string '/home/doron/workspace/myapp/application/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php' (length=103)
      'adapterClass' => string 'Doctrine\ORM\Mapping\Driver\AnnotationDriver' (length=44)
      'mappingNamespace' => string 'MyApp\Entity' (length=13)
      'mappingDirs' => 
    array
      0 => string '/home/doron/workspace/myapp/application/../library/MyApp/Entity' (length=65)
      'annotationReaderClass' => string 'Doctrine\Common\Annotations\AnnotationReader' (length=44)
      'annotationReaderCache' => string 'default' (length=7)

所以我可以看到 annotationRegistry属性位于数组内,而代码期望它不在数组内。

但这还不是结束,因为我也遇到了以下异常(在上一个异常之下):
Notice: Undefined index: drivers in /home/doron/workspace/myapp/library/Bisna/Doctrine/Container.php on line 571

所以我猜有些东西没有正确配置,或者 Bisna 有一个错误。

这是我的 application.ini:
[production]

; --------------------------
; PHP Specific Configuration
; --------------------------
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
phpSettings.date.timezone = "EST"

includePaths.library = APPLICATION_PATH "/../library"
includePaths.resource = APPLICATION "/../library/Bisna/Application/Resource"

; ----------------------------------------
; Zend Framework Application Configuration
; ----------------------------------------
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"

appnamespace = "Application"

autoloaderNamespaces[] = "MyApp"
autoloaderNamespaces[] = "Bisna"
autoloaderNamespaces[] = "Symfony"
autoloaderNamespaces[] = "Doctrine"

pluginPaths.Bisna\Application\Resource\ = "Bisna/Application/Resource"

; ------------------------------
; Front Controller Configuration
; ------------------------------
resources.frontController.controllerDirectory = APPLICATION_PATH "/controllers"
resources.frontController.params.displayExceptions = 0
resources.view[] =
resources.view.encoding = "UTF-8"
resources.view.doctype = "XHTML1_STRICT"
resources.view.contentType = "text/html; charset=UTF-8"

resources.layout.layoutPath = APPLICATION_PATH "/layouts/scripts/"

; ------------------------------------------------------------------------------
; Doctrine Class Loader Configuration
; ------------------------------------------------------------------------------

resources.doctrine.classLoader.loaderClass = "Doctrine\Common\ClassLoader"
resources.doctrine.classLoader.loaderFile  = APPLICATION_PATH "/../library/Doctrine/Common/ClassLoader.php"

resources.doctrine.classLoader.loaders.doctrine_common.namespace   = "Doctrine\Common"
resources.doctrine.classLoader.loaders.doctrine_common.includePath = APPLICATION_PATH "/../library"

resources.doctrine.classLoader.loaders.doctrine_dbal.namespace   = "Doctrine\DBAL"
resources.doctrine.classLoader.loaders.doctrine_dbal.includePath = APPLICATION_PATH "/../library"

resources.doctrine.classLoader.loaders.doctrine_orm.namespace   = "Doctrine\ORM"
resources.doctrine.classLoader.loaders.doctrine_orm.includePath = APPLICATION_PATH "/../library"

resources.doctrine.classLoader.loaders.symfony_console.namespace   = "Symfony\Component\Console"
resources.doctrine.classLoader.loaders.symfony_console.includePath = APPLICATION_PATH "/../library"

resources.doctrine.classLoader.loaders.symfony_yaml.namespace   = "Symfony\Component\Yaml"
resources.doctrine.classLoader.loaders.symfony_yaml.includePath = APPLICATION_PATH "/../library"


; ------------------------------------------------------------------------------
; Doctrine Cache Configuration
; ------------------------------------------------------------------------------

; Points to default cache instance to be used. Optional is only one cache is defined
resources.doctrine.cache.defaultCacheInstance = default

; Cache Instance configuration for "default" cache
resources.doctrine.cache.instances.default.adapterClass = "Doctrine\Common\Cache\MemcacheCache"
resources.doctrine.cache.instances.default.namespace    = "Application_"
resources.doctrine.cache.instances.default.options.servers.0.host = localhost
resources.doctrine.cache.instances.default.options.servers.0.port = 11211

; ------------------------------------------------------------------------------
; Doctrine DBAL Configuration
; ------------------------------------------------------------------------------

; Points to default connection to be used. Optional if only one connection is defined
resources.doctrine.dbal.defaultConnection = default

; Database configuration
;resources.doctrine.dbal.connections.default.parameters.wrapperClass = ""
resources.doctrine.dbal.connections.default.parameters.driver   = "pdo_mysql"
resources.doctrine.dbal.connections.default.parameters.dbname   = "myapp"
resources.doctrine.dbal.connections.default.parameters.host = "localhost"
resources.doctrine.dbal.connections.default.parameters.port = 3306
resources.doctrine.dbal.connections.default.parameters.user = "myapp"
resources.doctrine.dbal.connections.default.parameters.password = "myapp"
resources.doctrine.dbal.connections.default.parameters.charset = "utf-8"
resources.doctrine.dbal.connections.default.parameters.driverOptions.1002 = "SET NAMES 'UTF8'"


; ------------------------------------------------------------------------------
; Doctrine ORM Configuration
; ------------------------------------------------------------------------------

; Points to default EntityManager to be used. Optional if only one EntityManager is defined
resources.doctrine.orm.defaultEntityManager = default

; EntityManager configuration for "default" manager
resources.doctrine.orm.entityManagers.default.connection     = default
resources.doctrine.orm.entityManagers.default.proxy.autoGenerateClasses = false
resources.doctrine.orm.entityManagers.default.proxy.namespace           = "MyApp\Entity\Proxy"
resources.doctrine.orm.entityManagers.default.proxy.dir                 = APPLICATION_PATH "/../library/MyApp/Entity/Proxy"

resources.doctrine.orm.entityManagers.default.metadataDrivers.annotationRegistry.annotationFiles[]     = APPLICATION_PATH "/../library/Doctrine/ORM/Mapping/Driver/DoctrineAnnotations.php"

resources.doctrine.orm.entityManagers.default.metadataDrivers.0.adapterClass          = "Doctrine\ORM\Mapping\Driver\AnnotationDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.mappingNamespace      = "MyApp\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.mappingDirs[]         = APPLICATION_PATH "/../library/MyApp/Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.annotationReaderCache = default


[development : production]
phpSettings.display_startup_errors = 1
phpSettings.display_errors = 1
phpSettings.error_reporting = E_ALL | E_STRICT
resources.frontController.params.displayExceptions = 1

resources.doctrine.cache.instances.default.adapterClass = "Doctrine\Common\Cache\ArrayCache"
resources.doctrine.cache.instances.default.namespace    = "Application_"

最佳答案

这是我的错误,我没有注意到以下几行:

resources.doctrine.orm.entityManagers.default.metadataDrivers.0.adapterClass          = "Doctrine\ORM\Mapping\Driver\AnnotationDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.mappingNamespace      = "MyApp\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.mappingDirs[]         = APPLICATION_PATH "/../library/MyApp/Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
resources.doctrine.orm.entityManagers.default.metadataDrivers.0.annotationReaderCache = default

被重命名为
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.adapterClass          = "Doctrine\ORM\Mapping\Driver\AnnotationDriver"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingNamespace      = "MyApp\Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.mappingDirs[]         = APPLICATION_PATH "/../library/MyApp/Entity"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderClass = "Doctrine\Common\Annotations\AnnotationReader"
resources.doctrine.orm.entityManagers.default.metadataDrivers.drivers.0.annotationReaderCache = default

(注意 drivers 添加在 0 之前)。

关于zend-framework - 如何配置 Bisna 以与 Doctrine 2.1 和 Zend Framework 1.11.9 一起使用? [编辑 - 我的错误],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6896200/

相关文章:

jquery - zend/ajax 动态添加行的相关问题

zend-framework - 如何在基于 Zend Framework 的应用程序中的应用程序 Bootstrap 中使用模块中的模型类?

php - 无法转换属性路径的值 "fechaReclamacion": datefmt_format: string '' is not numeric

symfony - 在symfony(Doctrine)中更新实体时图片被删除

php - Symfony2 Doctrine 抛出 NonUniqueResultException

mysql - 使用 zend 连接到 MySQL

php - 如何使用 Gdata 从 Picasa 获取实际图像

zend-framework - Zend Framework 1.11 - 在 Application.ini 或 Bootstrap.php 中注册插件?

php - DBAL 基数违规错误

symfony - 原则 CASE WHEN THEN ELSE NULL