• <bdo id='9ZsMR'></bdo><ul id='9ZsMR'></ul>

  • <tfoot id='9ZsMR'></tfoot>
    <i id='9ZsMR'><tr id='9ZsMR'><dt id='9ZsMR'><q id='9ZsMR'><span id='9ZsMR'><b id='9ZsMR'><form id='9ZsMR'><ins id='9ZsMR'></ins><ul id='9ZsMR'></ul><sub id='9ZsMR'></sub></form><legend id='9ZsMR'></legend><bdo id='9ZsMR'><pre id='9ZsMR'><center id='9ZsMR'></center></pre></bdo></b><th id='9ZsMR'></th></span></q></dt></tr></i><div id='9ZsMR'><tfoot id='9ZsMR'></tfoot><dl id='9ZsMR'><fieldset id='9ZsMR'></fieldset></dl></div>

    <small id='9ZsMR'></small><noframes id='9ZsMR'>

    1. <legend id='9ZsMR'><style id='9ZsMR'><dir id='9ZsMR'><q id='9ZsMR'></q></dir></style></legend>

        Doctrine2 更新导致 Zend Framework 3 中的 AnnotationRegistry regist

        Doctrine2 Update Caused AnnotationRegistry registerLoader Error in Zend Framework 3(Doctrine2 更新导致 Zend Framework 3 中的 AnnotationRegistry registerLoader 错误)
      1. <i id='m1ouA'><tr id='m1ouA'><dt id='m1ouA'><q id='m1ouA'><span id='m1ouA'><b id='m1ouA'><form id='m1ouA'><ins id='m1ouA'></ins><ul id='m1ouA'></ul><sub id='m1ouA'></sub></form><legend id='m1ouA'></legend><bdo id='m1ouA'><pre id='m1ouA'><center id='m1ouA'></center></pre></bdo></b><th id='m1ouA'></th></span></q></dt></tr></i><div id='m1ouA'><tfoot id='m1ouA'></tfoot><dl id='m1ouA'><fieldset id='m1ouA'></fieldset></dl></div>
      2. <small id='m1ouA'></small><noframes id='m1ouA'>

      3. <legend id='m1ouA'><style id='m1ouA'><dir id='m1ouA'><q id='m1ouA'></q></dir></style></legend>
            <bdo id='m1ouA'></bdo><ul id='m1ouA'></ul>
              <tbody id='m1ouA'></tbody>

                • <tfoot id='m1ouA'></tfoot>
                  本文介绍了Doctrine2 更新导致 Zend Framework 3 中的 AnnotationRegistry registerLoader 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我正在开发基于 Zend Framework 3.0 的 CMS,以使用 Doctrine 管理 DB I.使用 Composer 管理包时有什么问题?最近,我将所有软件包更新为最新版本并将其发送到服务器,其他文件中没有任何更改.更新后,我的网站显示以下错误:

                  I'm working on a CMS based on Zend Framework 3.0 to manage a DB I with Doctrine. What is my problem when managing packages with composer? Recently, I updated all the packages to newest versions and sent it to server, nothing was changed in other files. After the update my site displayed the following error:

                  致命错误:未捕获的类型错误:DoctrineCommonAnnotationsAnnotationRegistry::registerLoader() 的返回值必须是 DoctrineCommonAnnotationsvoid 的一个实例,在/home/platne/serwer18346/vendor/doctrine 中没有返回/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117 堆栈跟踪:#0/home/platne/serwer18346/vendor/doctrine/doctrine-module/src/DoctrineModule/Module.php(57): DoctrineCommonAnnotationsAnnotationRegistry::registerLoader(Object(Closure)) #1/home/platne/serwer18346/vendor/zendframework/zend-modulemanager/src/Listener/InitTrigger.php(33): DoctrineModuleModule->init(Object(ZendModuleManagerModuleManager)) #2/home/platne/serwer18346/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): ZendModuleManagerListenerInitTrigger->__invoke(Object(ZendModuleManager)ModuleEvent)) #3/home/platne/serwer18346/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): ZendEventManagerEventManager->triggerListeners(Object(Zen)dModuleManagerModuleEvent)) #4/home/p in/home/platne/serwer18346/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php 117 行

                  Fatal error: Uncaught TypeError: Return value of DoctrineCommonAnnotationsAnnotationRegistry::registerLoader() must be an instance of DoctrineCommonAnnotationsvoid, none returned in /home/platne/serwer18346/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php:117 Stack trace: #0 /home/platne/serwer18346/vendor/doctrine/doctrine-module/src/DoctrineModule/Module.php(57): DoctrineCommonAnnotationsAnnotationRegistry::registerLoader(Object(Closure)) #1 /home/platne/serwer18346/vendor/zendframework/zend-modulemanager/src/Listener/InitTrigger.php(33): DoctrineModuleModule->init(Object(ZendModuleManagerModuleManager)) #2 /home/platne/serwer18346/vendor/zendframework/zend-eventmanager/src/EventManager.php(322): ZendModuleManagerListenerInitTrigger->__invoke(Object(ZendModuleManagerModuleEvent)) #3 /home/platne/serwer18346/vendor/zendframework/zend-eventmanager/src/EventManager.php(171): ZendEventManagerEventManager->triggerListeners(Object(ZendModuleManagerModuleEvent)) #4 /home/p in /home/platne/serwer18346/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationRegistry.php on line 117

                  如果需要一些应用程序代码:
                  模块:

                  Some application code if needed:
                  modules:

                  return [
                      'ZendRouter',
                      'ZendValidator',
                      'DoctrineModule',
                      'DoctrineORMModule',
                      'Core',
                  ];
                  

                  development.local(开发者模式已激活):

                  development.local(developer mode is active):

                  'doctrine' => [
                          'connection' => [
                              'orm_default' => [
                                  'driverClass' => DoctrineDBALDriverPDOMySqlDriver::class,
                                  'params' => [
                                      'host' => '******',
                                      'user' => '*******',
                                      'password' => '******',
                                      'dbname' => '*******',
                                      'charset' => 'utf8'
                                  ]
                              ]
                          ]
                      ]
                  

                  module.config:

                  module.config:

                  'doctrine' => [
                          'driver' => [
                              __NAMESPACE__ . '_driver' => [
                                  'class' => AnnotationDriver::class,
                                  'cache' => 'array',
                                  'paths' => [__DIR__.'/../src/Model']
                              ],
                              'orm_default' => [
                                  'drivers' => [
                                      __NAMESPACE__ . 'Model' => __NAMESPACE__ . '_driver'
                                  ]
                              ]
                          ]
                      ]
                  

                  控制器工厂:

                  public function __invoke(ContainerInterface $container,$requestedName, array $options = null)
                  {
                      $controllerInstance = null;
                      switch($requestedName){
                          case 'CoreControllerIndexController': $controllerInstance = $this->_invokeIndex($container); break;
                          case 'CoreControllerPagesController': $controllerInstance = $this->_invokePages($container); break;
                      }
                      return $controllerInstance;
                  }
                  
                  protected function _invokeIndex(ContainerInterface $container)
                  {
                      return new ControllerIndexController(
                          $container->get('doctrine.entitymanager.orm_default')
                      );
                  }
                  
                  protected function _invokePages(ContainerInterface $container)
                  {
                      return new ControllerPagesController(
                          $container->get('doctrine.entitymanager.orm_default')
                      );
                  }
                  

                  控制器父级:

                   protected $_entityManager;
                  
                      /**
                       * AppController constructor.
                       * @param EntityManager $entityManager
                       */
                      public function __construct(EntityManager $entityManager)
                      {
                          $this->_entityManager = $entityManager;
                      }
                  
                      /**
                       * @return EntityManager
                       */
                      public function getEntityManager()
                      {
                          return $this->_entityManager;
                      }
                  

                  正如我所说,此代码在更新前有效.更新后它向我显示该错误,更重要的是在上传以前的版本后错误仍然存在.我尝试重写代码,但效果相同.

                  As I said this code worked before update. After update it show me that error, what is more after uploading previous versions the error remains. I triead rewriting code but with the same effect.

                  作曲家(没有项目数据):

                  Composer(without project data):

                  "require": {
                      "zendframework/zend-mvc": "*",
                      "zendframework/zend-developer-tools": "*",
                      "zendframework/zend-session": "*",
                      "zendframework/zend-authentication": "*",
                      "zfcampus/zf-development-mode": "*",
                      "doctrine/doctrine-orm-module": "*"
                    },
                    "autoload": {
                      "psr-4": {
                        "Core\": "module/Core/src/"
                      }
                    }
                  

                  推荐答案

                  这个错误是由最新版本的DoctrineCommonAnnotations使用PHP 7.1引起的.这就是为什么它使用 void 作为 return type.并且它在 PHP 7.0.* 上不受支持.这是PHP 7.1 中的新功能

                  This error caused by the latest version of DoctrineCommonAnnotations use PHP 7.1. That's why it use void as return type. And it is not supported on PHP 7.0.*. This is new feature in PHP 7.1

                  我在使用 PHP 7.0 的 ZF3 项目中使用 doctrine-orm-module 1.1.它运作良好.因此,只需将您的 doctrine-orm-module 版本替换为 1.1.

                  I use doctrine-orm-module 1.1 in my ZF3 project using PHP 7.0. And it work well. So, just replace your doctrine-orm-module version to 1.1.

                  "doctrine/doctrine-orm-module": "^1.1"
                  

                  我建议你定义你在 composer.json 中使用的依赖版本.这是为了让你的项目在新版本的依赖发布时不会被破坏.

                  I suggest you to define the version of dependencies you used in composer. This is purposed to make your project not broken when new version of dependencies released.

                  这篇关于Doctrine2 更新导致 Zend Framework 3 中的 AnnotationRegistry registerLoader 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Zend_Controller_Router_Exception: quot;xyzquot; is not specified(Zend_Controller_Router_Exception:“xyz;未指定)
                  Zend_Db_Table subquery(Zend_Db_Table 子查询)
                  pcntl_fork and the MySQL connection is gone(pcntl_fork 和 MySQL 连接消失了)
                  Change layout in the controller of Zend Framework 2.0(在 Zend Framework 2.0 的控制器中更改布局)
                  Zend Mail Gmail SMTP(Zend 邮件 Gmail SMTP)
                  Zend_Form: how to check 2 fields are identical(Zend_Form:如何检查 2 个字段是否相同)

                  <legend id='gBVqg'><style id='gBVqg'><dir id='gBVqg'><q id='gBVqg'></q></dir></style></legend>

                  <small id='gBVqg'></small><noframes id='gBVqg'>

                  <tfoot id='gBVqg'></tfoot>
                    <bdo id='gBVqg'></bdo><ul id='gBVqg'></ul>
                      <tbody id='gBVqg'></tbody>
                    • <i id='gBVqg'><tr id='gBVqg'><dt id='gBVqg'><q id='gBVqg'><span id='gBVqg'><b id='gBVqg'><form id='gBVqg'><ins id='gBVqg'></ins><ul id='gBVqg'></ul><sub id='gBVqg'></sub></form><legend id='gBVqg'></legend><bdo id='gBVqg'><pre id='gBVqg'><center id='gBVqg'></center></pre></bdo></b><th id='gBVqg'></th></span></q></dt></tr></i><div id='gBVqg'><tfoot id='gBVqg'></tfoot><dl id='gBVqg'><fieldset id='gBVqg'></fieldset></dl></div>