user2501247
user2501247

Reputation: 109

ZF3 Navigation "plugin" error

Following https://docs.zendframework.com/zend-navigation/quick-start/, i try to make a navigation for my application. I registered a navigation, i added the DefaultNavigationFactory to the service-manager, but i get an error when i try to print the navigation.

This is my module/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,
    ],
],
];

But when $this->navigation('default')->menu(), i get this error, excluding the stack trace:

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

Upvotes: 4

Views: 1926

Answers (4)

macieklag
macieklag

Reputation: 11

Check your "development mode". In production mode, 'config_cache_enabled' is true. When you install new module, you must refresh cache. Default: 'data/cache/module-config-cache.application.config.cache.php'

Upvotes: 1

NiMeDia
NiMeDia

Reputation: 1004

In addition to the answer of @Ponsjuh I had to include the module "Zend\Navigation" in my modules config.

Upvotes: 3

Azhar Ahmad
Azhar Ahmad

Reputation: 183

you need to pass 'navigation' instead of 'default' as below:

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

Upvotes: 1

Ponsjuh
Ponsjuh

Reputation: 468

Running

composer require zendframework/zend-navigation

fixed the issue it seems that in zf3 navigation isn't installed by default

Upvotes: 4

Related Questions