我得到一個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
就是這樣!我有一個模塊導航....請發佈這個答案,所以我可以選擇你! –
我現在嘗試合併來自不同模塊的多個導航配置時出現另一個錯誤:無效參數:無法確定類來實例化......任何想法? –