• <legend id='i4yiG'><style id='i4yiG'><dir id='i4yiG'><q id='i4yiG'></q></dir></style></legend>
  • <tfoot id='i4yiG'></tfoot>
    • <bdo id='i4yiG'></bdo><ul id='i4yiG'></ul>

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

        Doctrine2 更新导致 Zend Framework 3 中的 AnnotationRegi

        时间:2023-10-02
      1. <i id='NH8LI'><tr id='NH8LI'><dt id='NH8LI'><q id='NH8LI'><span id='NH8LI'><b id='NH8LI'><form id='NH8LI'><ins id='NH8LI'></ins><ul id='NH8LI'></ul><sub id='NH8LI'></sub></form><legend id='NH8LI'></legend><bdo id='NH8LI'><pre id='NH8LI'><center id='NH8LI'></center></pre></bdo></b><th id='NH8LI'></th></span></q></dt></tr></i><div id='NH8LI'><tfoot id='NH8LI'></tfoot><dl id='NH8LI'><fieldset id='NH8LI'></fieldset></dl></div>

            <legend id='NH8LI'><style id='NH8LI'><dir id='NH8LI'><q id='NH8LI'></q></dir></style></legend>
              <tbody id='NH8LI'></tbody>
            • <tfoot id='NH8LI'></tfoot>

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

                <bdo id='NH8LI'></bdo><ul id='NH8LI'></ul>
                1. 本文介绍了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 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:使用 Doctrine 2 转储数据库数据 下一篇:如何在不安装 Zend Framework 的情况下使用 Zend 库

                  相关文章

                  最新文章

                  <i id='75JIK'><tr id='75JIK'><dt id='75JIK'><q id='75JIK'><span id='75JIK'><b id='75JIK'><form id='75JIK'><ins id='75JIK'></ins><ul id='75JIK'></ul><sub id='75JIK'></sub></form><legend id='75JIK'></legend><bdo id='75JIK'><pre id='75JIK'><center id='75JIK'></center></pre></bdo></b><th id='75JIK'></th></span></q></dt></tr></i><div id='75JIK'><tfoot id='75JIK'></tfoot><dl id='75JIK'><fieldset id='75JIK'></fieldset></dl></div>
                      <legend id='75JIK'><style id='75JIK'><dir id='75JIK'><q id='75JIK'></q></dir></style></legend>

                      <small id='75JIK'></small><noframes id='75JIK'>

                    1. <tfoot id='75JIK'></tfoot>

                        <bdo id='75JIK'></bdo><ul id='75JIK'></ul>