我得到一个Zend 2导航误差,并且似乎无法找到它的解决方案。搜索一切,想尽一切.....Zend框架2导航误差
这里是我的CONFIGS:
路线(Application/config/module.config.php)
:
'home' => array(
'type' => 'Zend\Mvc\Router\Http\Literal',
'options' => array(
'route' => '/',
'defaults' => array(
'controller' => 'Application\Controller\Index',
'action' => 'index',
),
),
),
工厂(Application/config/module.config.php)
:
'service_manager' => array(
'factories' => array(
'navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
),
导航(Application/config/module.config.php)
:
'navigation' => array(
'default' => array(
array(
'label' => 'home',
'route' => 'home',
),
),
),
布局(Application\view\layout\layout.phtml)
:
<?php echo $this->navigation('navigation')->menu(); ?>
错误:
Uncaught exception 'Zend\Navigation\Exception\InvalidArgumentException' with message 'Invalid argument: $route must be a non-empty string or null' in
/var/www/html/project/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 904
和
Zend\Navigation\Exception\InvalidArgumentException: Invalid argument: $route must be a non-empty string or null in /var/www/html/project/vendor/zendframework/zendframework/library/Zend/Navigation/Page/Mvc.php on line 397
前一个异常:
Zend\ServiceManager\Exception\ServiceNotCreatedException: An exception was raised while
creating "navigation"; no instance returned in /var/www/html/project/vendor/zendframework/zendframework/library/Zend/ServiceManager/ServiceManager.php on line 904
什么问题?我似乎无法得到它的工作,...
您的配置看起来这里的罚款;虽然错误表示你将'null'作为'route'值传递给'Mvc'类。请记住,如果在其他模块('module.config.php')中有任何其他导航配置,它们在引导期间也将包含在工厂中。 – AlexP
就是这样!我有一个模块导航....请发布这个答案,所以我可以选择你! –
我现在尝试合并来自不同模块的多个导航配置时出现另一个错误:无效参数:无法确定类来实例化......任何想法? –