This post is a  follow up from : zend framework 2 acl in 5 minutes

Step 1

Code in config/autoload/global.php

'navigation' => array(
    'default'=> array(
      	array(
	    'label' => 'Home',
            'route' => 'home',
            'resource'=> 'home',
        ),
      	array(
	    'label' => 'Login',
            'route' => 'login',
            'resource'=> 'login',
        ),
      	array(
	    'label' => 'Register',
            'route' => 'register',
            'resource'=> 'register',
        ), 
    )
)

Step 2

Code in layout.phtml

echo $this->navigation('Navigation')->setAcl($this->acl)->setRole('guest');

Step 3

Add navigation factory in the config

Code in module.config.php

'service_manager' => array(
    'factories' => array(
       'Navigation' => 'Zend\Navigation\Service\DefaultNavigationFactory',
    ),
 ),

Simple as that.

Suggestions or problems ? Write a comment.