Laminas navigation error when rendering

Hello everyone. I’m trying to set up my navigation menu in my project but I get this error :

Fatal error: Uncaught Laminas\Navigation\Exception\InvalidArgumentException: Invalid argument: Unable to determine class to instantiate in C:\wamp\www\sigpip\vendor\laminas\laminas-navigation\src\Page\AbstractPage.php:267 Stack trace: #0 C:\wamp\www\sigpip\vendor\laminas\laminas-navigation\src\AbstractContainer.php(131): Laminas\Navigation\Page\AbstractPage::factory(Array) #1 C:\wamp\www\sigpip\vendor\laminas\laminas-navigation\src\AbstractContainer.php(182): Laminas\Navigation\AbstractContainer->addPage(Array) #2 C:\wamp\www\sigpip\vendor\laminas\laminas-navigation\src\Navigation.php(36): Laminas\Navigation\AbstractContainer->addPages(Array) #3 C:\wamp\www\sigpip\vendor\laminas\laminas-navigation\src\Service\AbstractNavigationFactory.php(43): Laminas\Navigation\Navigation->__construct(Array) #4 C:\wamp\www\sigpip\vendor\laminas\laminas-servicemanager\src\ServiceManager.php(642): Laminas\Navigation\Service\AbstractNavigationFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), 'Laminas\\Navigat...', NULL) #5 C:\wamp\www\sigpip\vendor\laminas\laminas-servicemanager\src\ServiceManager.php(264): Laminas\ServiceManager\ServiceManager->doCreate('Laminas\\Navigat...') #6 C:\wamp\www\sigpip\vendor\laminas\laminas-view\src\Helper\Navigation\AbstractHelper.php(

Here are some parts of my code :

navigation.config.php

<?php

/**
 * @package    Config
 * @subpackage Navigation
 * @author     Samuel Nangui <nanguisamuel@gmail.com>
 * @copyright  Copyright (c) 2025 NSLabs
 */
//Inclusions des pages de chaque root menu
include 'nav-module/accueil.config.php';
include 'nav-module/cartographie.config.php';
include 'nav-module/documentation.config.php';
include 'nav-module/impression.config.php';
include 'nav-module/projet-pip.config.php';
include 'nav-module/mon-compte.config.php';
//Inclusions des pages de chaque root menu


$navigations = [
        'default' => [
            [
                'label' => 'menu-accueil',
                'route' => 'front-user',  
                'action' => 'index',                
                'resource' => 'index',
            ],
            [
                'label' => 'menu-projet-pip',
                'route' => null,                
                'resource' => 'ressource-menu-projet-pip',
                'pages' => $pagesProjetPip,
            ],
            [
                'label' => 'menu-impression',
                'route' => null,                
                'resource' => 'ressource-menu-impression',
                'pages' => $pagesImpression,
            ],
            [
                'label' => 'menu-documentation',
                'route' => 'documentation',                
                'resource' => 'ressource-menu-documentation',
                'pages' => [],
            ],
            [
                'label' => 'menu-cartographie',
                'route' => 'cartographie',                
                'resource' => 'ressource-cartographie',
                'pages' => [],
            ],
            [
                'label' => 'menu-mon-compte',
                'route' => null,                
                'resource' => 'ressource-menu-mon-compte',
                'pages' => $pagesMonCompte,
            ],
        ],
    ];

autoload\global.php

return [    
    ......................... // Removed unnecessary part for the post
    
    
    'session_containers' => [
        'I18nSessionContainer'
    ],
    
    'navigation' => $navigations,    
];

In my menu, calling navigation with partial.

<?php                        
                        //$this->navigation('default')->menu()->setPartial('partial/top-nav.phtml');
                        $this->navigation()->menu('default')->setPartial('partial/top-nav.phtml');
                        echo $this->navigation()->menu()->render();
                     ?>

Any issue will be appreciated.
Thanks

I need to sy that tn a previous project (year 2024), I set up my navigation menu like this and it was ok

This will not work because:

An option could # as uri.


The configuration of the entire navigation container can be simplified, because if you store everything under the same array key – in your case default, it is automatically merged. No extra includes needed.

got it @froschdesign . Lemme try and get back to you.
Thanks

I removed the null value still does not work

See my suggestion from above:

I tried your suggestion, I get no error but the menu is empty

When I do var_dump($this->container); I get this

Which one? Using the # as value for uri of a page or to remove the includes in your configuration files?

I tried this one # . There are no more errors but navigation menu is empty.

Even if I try with the simple menu in this tuto Quick Start - laminas-navigation - Laminas Docs
Section Using multiple navigations , I get empty nav menu

I do not use any factory.
I have just installed laminas/laminas-navigation ,
put the ‘navigation’ key in autoload\global.php file and then called in my partial menu. That was all I do.

Please try to get the navigation container yourself. This can be done very early in the index.php of your application:

Check the result and the pages.

Ok ok.
I will try this and keep you posted

Found the error. I render the menu like this :

$this->navigation('navigation')->menu('default')->setPartial('/partial/top-nav.phtml');

Instead of $this->navigation()->menu('default')->setPartial('/partial/top-nav.phtml');

Some more options:

$this->navigation('default')->menu()->setPartial('/partial/top-nav.phtml');

$this->navigation()->menu()->setPartial('/partial/top-nav.phtml')->render('default');

You can set the name of navigation container on the proxy helper navigation or on the concrete helper like menu or on the render method.

1 Like

Thanks to you @froschdesign