I encountered the following issue when I have moved Magento 2 module into production with the command setup:di: compile

Uncaught Error: Call to a member function setActive() on boolean in /opt/bitnami/apps/magento/htdocs/vendor/magento/module-backend/Model/View/Result/Page.php:27\nStack trace: /opt/bitnami/apps/magento/htdocs/generated/code/Magento/Backend/Model/View/Result/Page/Interceptor.php(24): Magento\Backend\Model\View\Result\Page->setActiveMenu('...')

I found a solution to delete magento\generated\metadata\global.php file which worked.

Does anyone know the purpose of global.php file and is it safe to delete it?

Thanks in advance.

  • I would look for any errors that occur while Magento is in developer mode, without running di:compile. You'll want to find a root cause of your issue, rather than trying to delete core Magento files.
    – andyjv
    Jan 18, 2019 at 15:01

3 Answers 3


As the documentation says

"The code compiler creates generated/metadata/global.php, which is a PHP serialized map of all constructor definitions mixed with object linking configuration defined in di.xml. di.xml is the dependency injection configuration. There is a global app/etc/di.xml and there can one defined for every module ."


I do not recommend to delete the file, as Magento is running in Developer mode without it, as ConfigLoader\Compiled::getFilePath(Area::AREA_GLOBAL) resolves to /generated/metadata/global.php:

 private function getMode()
    if (file_exists(ConfigLoader\Compiled::getFilePath(Area::AREA_GLOBAL))) {
        return Compiled::MODE;

    return Developer::MODE;

Well looking into M2 core if the global.php is missing it runs the environment in developer mode rather than compiled mode (check vendor/magento/framework/App/EnvironmentFactory.php getMode method). I have no idea what that means in terms of performance and why running in compiled mode causes the error you mentioned since none of this is documented...

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.