migrationzend-framework3zend-servicemanager

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


I'm migrating a ZF2 application to ZF3.

First I was getting the error:

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

Adding of 'Zend\Router' to the modules array in the application.config.php solved the issue. But now I'm getting another error:

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

What might cause this error and how to fix it?


Solution

  • Caused by Zend\Mvc\Router has been moved to Zend\Router, so just replace Zend\Mvc\Router\Http\Segment to Zend\Router\Http\Segment