2016-07-25 47 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'