I tried to inject a registry class in my controllers constructor, without this registry class, it works (the die('Ok') is displayed ) but when I add the class, it breaks my page, I mean (I have a white page without any error or log) ?

For More info: I'm in developer mode, the other errors are well displayed but not this one, I don't know if there is really an error or not I don't know !

php bin/magento deploy:mode:show

Current application mode: developer. (Note: Environment variables may override this value.)

class Index extends \Magento\Framework\App\Action\Action
    protected $_resultPageFactory;
    protected $_coreRegistry;

    public function __construct
        \Magento\Framework\App\Action\Context $context,
        \Magento\Framework\Registry $coreRegistry,
        \Magento\Framework\View\Result\PageFactory $resultPageFactory
        $this->_coreRegistry = $coreRegistry;
        $this->_resultPageFactory = $resultPageFactory;

    public function execute()
  • Try modifying protected $_coreRegistry = null; Feb 9, 2018 at 19:33
  • What does log say? Feb 9, 2018 at 19:33
  • Can you add more information please. You say it breaks your page, how does it break your page, do you get an error? white page? half a page? anything in your system or exception log?
    – DanCarlyon
    Feb 9, 2018 at 19:34
  • @Abhishek Panchal I tried it but i have the same thing
    – PЯINCƎ
    Feb 9, 2018 at 19:37
  • 1
    @Prince Check app/boostrap.php file. You have to uncomment ini_set('display_errors', 1); to see errors Feb 10, 2018 at 7:19

1 Answer 1


I solved my problem, I didn't know that it was necessary to regenerate the code, empty the var/ and generated/ folders every time we want to inject classes into the a constructor, and so it solved my problem.

So we must need to remove the var and generated content without the .htacess

Why should you regenerate code?

Suppose a Customer or Proxy class for a Customer class is generated and the Customer class has new methods added to it. Because a Customer or Proxy exists on the file system, it is not regenerated. However, the Customer or Proxy implementation is incomplete now because it does not have the new methods. In this case, you must regenerate the Customer or Proxy class.

If the code generator implementation itself is changed, you must regenerate all the classes. This is rare, however.

More information here in Magento DevDocs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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