Ever faced blank pages issue after compilation command in Magento 2? or ever got the fatal error that states:
Uncaught Error: Call to a member function setActive() on boolean
The variety of tasks depends on the ‘php bin/magento setup:di:compile ‘command in Magento 2 store.
Especially while working with dependency injection configuration, repositories code generation, and application code generation, need often arrives to use the compilation command.
I’ve observed many of us tend to delete the ‘generated’ folder to solve this issue.
By default, Magento generates code to create non-existent factory classes if the class is injected in a constructor and stores all of Magento’s code in the ‘generated’ folder.
Hence, for this particular issue, it’s not always advisable to delete the whole generated folder. Instead of this, it is recommended to use the below solution:
Solution to Blank Pages Issue After Compilation Command in Magento 2:
This issue arrives because the globle.php file gets generated after the compilation command.
Therefore, instead of removing the complete generated folder; remove the globle.php file located at generated\metadata\
Refresh your page.
And you are done! The page will work the same as before.
If you have any doubts regarding this solution, just mention them in the Comments section below.
I would be happy to help.
Feel free to share the solution with Magento Community via social media.
Get Weekly Updates
Never miss Magento tips, tricks, tutorials, and news.
Thank you for subscribing.
Something went wrong.