Reputation: 409
I am using the flash messenger plugin in Zend Framework 2. I can set messages in the controller's action, that's no problem:
$this->flashMessenger()->addMessage('You are now logged in.');
But when I try to call it in the view, as it is described in the official Zend Framework documentation (https://framework.zend.com/manual/2.3/en/modules/zend.view.helpers.flash-messenger.html), I get an error:
Fatal error: Class 'Zend\Mvc\Controller\Plugin\FlashMessenger' not found in /Applications/XAMPP/xamppfiles/htdocs/zend/vendor/zendframework/zend-view/src/Helper/Service/FlashMessengerFactory.php on line 33
I read the documentation and did not find any information about initialization before using it. What I can do is passing the messages to the view, but if the documentation says it is possible to use the plugin in the view, I would prefer to use it like that and not pass an array of messages to the view.
The module is also listed in my modules.config.php:
return [
'Zend\ServiceManager\Di',
'Zend\Session',
'Zend\Mvc\Plugin\Prg',
'Zend\Mvc\Plugin\Identity',
'Zend\Mvc\Plugin\FlashMessenger',
'Zend\Mvc\Plugin\FilePrg',
'Zend\Mvc\I18n',
'Zend\Mvc\Console',
'Zend\Log',
'Zend\Form',
'Zend\Db',
'Zend\Cache',
'Zend\Router',
'Zend\Validator',
'Album',
'Application',
'User',
];
Upvotes: 0
Views: 1228