在https://docs.zendframework.com/zend-navigation/quick-start/之后,我尝试为我的应用程序制作导航。我注册了导航,我将DefaultNavigationFactory添加到服务管理器,但是当我尝试打印导航时出现错误。
这是我的模块/ Application / config / 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
答案 0 :(得分:3)
正在运行
composer require zendframework/zend-navigation
修复了zf3导航默认情况下未安装的问题
答案 1 :(得分:3)
除了@Ponsjuh的答案之外,我还必须包含模块" Zend \ Navigation"在我的模块配置中。
答案 2 :(得分:2)
检查您的"开发模式"。在生产模式中,' config_cache_enabled'是真的。安装新模块时,必须刷新缓存。 默认值:' data / cache / module-config-cache.application.config.cache.php'
答案 3 :(得分:1)
你需要通过导航'而不是'默认'如下:
$this->navigation('navigation')->menu();