I'm trying to use the message manager in magento2 (admin side) by object injection but when i add it to my controller - my controller doesn't run.

class Example
    protected $_messageManager;

    public function __construct(
        \Magento\Framework\Message\ManagerInterface $messageManager
    ) {
        $this->_messageManager = $messageManager;

    public function method( ) {
        $message = '...';
  • clear the contents of var/generation. – Marius Nov 10 '15 at 8:14
  • Cool! it almost works... Now it shows the error message only when I refresh the admin page. – Omry Zobel Nov 10 '15 at 8:26

Implementation of \Magento\Framework\Message\ManagerInterface - \Magento\Framework\Message\Manager uses sessons. Try to clean browser cookies

| improve this answer | |
  • I tried opening it in incognito but still i need to refresh the page in order to see the message. – Omry Zobel Nov 11 '15 at 10:25
  • Try to clean cookies and brwoser cache, not incognito mode. Try also clean up /var directory – Arkadii Chyzhov Nov 11 '15 at 19:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.