Question

Possible Duplicate:
How to add custom view helpers to Zend Framework 2

I keep getting ServiceNotFoundExceptions when attempting to load a view helper in ZF2. My module configuration is as follows:

'view_manager' => [
    'template_path_stack' => [
        'stock' => __DIR__ . '/../view'
    ],
    'invokables' => [
        'navlink' => 'Application\View\Helper\NavLinkHelper'
    ]
]

The class doesn't seem to be added to the plugin registry. I've found several different methods posted over the past 6 months, none of which work. Apparently the official documentation (suggesting use of helper_map) is also out-of-date. Any ideas?

Was it helpful?

Solution

Modify your module.config.php to include the following array. Please notice the difference of the array_key used to declare the helper-mapping.

return array(
    'view_helpers' => array(
        'invokables' => array(
            'navlink' => 'Application\View\Helper\NavLinkHelper'
        )
    )
);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top