4

https://docs.zendframework.com/zend-navigation/quick-start/之后,我尝试为我的应用程序进行导航。我注册了一个导航,我将 DefaultNavigationFactory 添加到服务管理器,但是当我尝试打印导航时出现错误。

这是我的模块/应用程序/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
4

4 回答 4

4

跑步

composer require zendframework/zend-navigation

修复了zf3中默认没有安装导航的问题

于 2016-08-05T09:19:31.250 回答
3

除了@Ponsjuh 的答案,我还必须在我的模块配置中包含模块“Zend\Navigation”。

于 2016-12-08T14:36:22.300 回答
1

检查您的“开发模式”。在生产模式下,“config_cache_enabled”为真。安装新模块时,必须刷新缓存。默认值:'data/cache/module-config-cache.application.config.cache.php'

于 2017-04-04T08:30:25.113 回答
1

您需要传递“导航”而不是“默认”,如下所示:

 $this->navigation('navigation')->menu();
于 2016-11-16T16:50:23.497 回答