2016-07-25 66 views
3

正在關注https://docs.zendframework.com/zend-navigation/quick-start/,我嘗試爲我的應用程序進行導航。我註冊了一個導航,我將DefaultNavigationFactory添加到服務管理器,但是當我嘗試打印導航時出現錯誤。ZF3導航「插件」錯誤

這是我的模塊/應用/配置/ module.config.php:

namespace Application; 

use Zend\Navigation\Service\DefaultNavigationFactory; 
use Zend\ServiceManager\Factory\InvokableFactory; 
use Zend\View\Helper\Navigation; 

return [ 
'navigation' => [ 
    'default' => [ 
     /* ... */ 
    ] 
] , 

'service_manager' => [ 
    'factories' => [ 
     'navigation' => DefaultNavigationFactory::class, 
    ], 
], 
]; 

但當$this->navigation('default')->menu(),我得到這個錯誤,不包括堆棧跟蹤:

Fatal error: Uncaught Zend\ServiceManager\Exception\ServiceNotFoundException: A plugin by the name "navigation" was not found in the plugin manager Zend\View\HelperPluginManager in C:\Users\bikke_000\Documents\Sites\slapenenzo\vendor\zendframework\zend-servicemanager\src\AbstractPluginManager.php:133 

回答

3

運行

composer require zendframework/zend-navigation

修復了這個問題似乎是臨時性的噸ZF3導航默認情況下不

1

安裝你需要通過「導航」而不是「默認」,如下:

$this->navigation('navigation')->menu(); 
3

除了@Ponsjuh的答案,我必須包括的模塊「Zend \ Navigation」在我的模塊配置中。

1

檢查您的「開發模式」。在生產模式下,'config_cache_enabled'爲true。當您安裝新模塊時,您必須刷新緩存。 默認值:'data/cache/module-config-cache.application.config.cache.php'