将 ZF2 迁移到 ZF3:在插件管理器中找不到 Zend\Mvc\Router\Http\Segment

Migrating ZF2 to ZF3: Zend\Mvc\Router\Http\Segment was not found in the plugin manager

我正在将 ZF2 应用程序迁移到 ZF3。

首先我收到错误:

Fatal error: Uncaught Zend\ModuleManager\Listener\Exception\RuntimeException: Could not find a valid ServiceManager for RoutePluginManager in /var/www/work/path/to/project/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 202
Zend\ModuleManager\Listener\Exception\RuntimeException: Could not find a valid ServiceManager for RoutePluginManager in /var/www/work/path/to/project/vendor/zendframework/zend-modulemanager/src/Listener/ServiceListener.php on line 202

'Zend\Router' 添加到 application.config.php 中的 modules 数组解决了这个问题。但现在我又遇到了另一个错误:

Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: A plugin by the name "Zend\Mvc\Router\Http\Segment" was not found in the plugin manager Zend\Router\RoutePluginManager in /var/www/work/path/to/project/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 131
Zend\ServiceManager\Exception\ServiceNotFoundException: A plugin by the name "Zend\Mvc\Router\Http\Segment" was not found in the plugin manager Zend\Router\RoutePluginManager in /var/www/work/path/to/project/vendor/zendframework/zend-servicemanager/src/AbstractPluginManager.php on line 131

什么可能导致此错误以及如何解决?

Zend\Mvc\Router 引起的已移至 Zend\Router,因此只需将 Zend\Mvc\Router\Http\Segment 替换为 Zend\Router\Http\Segment