Magento blank page issue: How to resolve it after installing Magento 2.x

Magento blank page

Magento blank page issue is a common problem you will face when work on Magento 2. This error often occur when you upgrade, migrate or perform a fresh Magento 2 installation whether it is Community Edition or Enterprise Edition. So what actually is the reason behind this error? and how to fix it? Let’s follow this post, we will show you some reasons why it happens,  as well as solutions on how to resolve

How to resolve Magento blank page issue after installing Magento 2.x

Magento 2 is complex and sometimes, errors may not  in Live environment, but do occur in local environment. It’s necessary to understand the cause of the error so that we can solve the issues the next time we encounter them.

Causes for the  Magento blank page issue

When you install Magento 2, you can encounter many issues like not supporting PHP versions with Magento, no PHP extension installed, and many more. This post today, we are going to talk about one of those errors. Which is to do a blank show of the admin page after the installation of Magento 2. To fix this issue, we need to know a little bit of code.

Read more: Magento 2 blank admin page: The effective ways to solve it

To do the same first you need to open “Validator.php” file located at below path.
Approximately around line number 133, you will find this feature.

 protected function isPathInDirectories($path, $directories)
Now inside this function find out this code.
$realPath = $this->fileDriver->getRealPath($path);
Next step, you replace it with the below code.
$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
That’s it now open your command line interface (CLI) and use the below command.
php bin/magento cache:clean
php bin/magento cache:flush
php bin/magento indexer:reindex
php bin/magento setup:upgrade
php bin/magento setup:static-content:deploy -f

How to fix blank admin page on Magento 2.3 in Windows

The reason for the invalid template file is the difference between the use of “/” and “\” in the path. Windows uses “/” while Magento uses “\”.

The exception dialog box will show like this:

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: ‘E:/Working/xampp/htdocs/magento233sd/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml’ in module: ‘Magento_Backend’ block’s name: ‘require.js’

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: ‘E:/Working/xampp/htdocs/magento233sd/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml’ in module: ‘Magento_Backend’ block’s name: ‘require.js’

#1 Magento\Framework\View\Element\Template->_toHtml() called at [vendor\magento\framework\View\Element\AbstractBlock.php:1097]
#2 Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element\{closure}() called at [vendor\magento\framework\View\Element\AbstractBlock.php:1101]
#3 Magento\Framework\View\Element\AbstractBlock->_loadCache() called at [vendor\magento\framework\View\Element\AbstractBlock.php:671]
#4 Magento\Framework\View\Element\AbstractBlock->toHtml() called at [vendor\magento\framework\View\Result\Page.php:249]
#5 Magento\Framework\View\Result\Page->render(&Magento\Framework\App\Response\Http\Interceptor#00000000539c0a3500000000105dec46#) called at [vendor\magento\framework\View\Result\Layout.php:171]
#6 Magento\Framework\View\Result\Layout->renderResult(&Magento\Framework\App\Response\Http\Interceptor#00000000539c0a3500000000105dec46#) called at [generated\code\Magento\Backend\Model\View\Result\Page\Interceptor.php:193]
#7 Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(&Magento\Framework\App\Response\Http\Interceptor#00000000539c0a3500000000105dec46#) called at [vendor\magento\framework\App\Http.php:141]
#8 Magento\Framework\App\Http->launch() called at [generated\code\Magento\Framework\App\Http\Interceptor.php:24]
#9 Magento\Framework\App\Http\Interceptor->launch() called at [vendor\magento\framework\App\Bootstrap.php:261]
#10 Magento\Framework\App\Bootstrap->run(&Magento\Framework\App\Http\Interceptor#00000000539c0a3e00000000105dec46#) called at [index.php:39]

To solve it, move to the Magento folder you have installed.

Next, go to vendor->magento->framework->View->Element->Template->File->Validator.php

You find out the code line:

$realPath = $this->fileDriver->getRealPath($path);

Magento blank page

Then replace to:

$realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));


Note: We sugggest you that you keep the old code line for future use. To hide it, use “//” before the code line. Thus, the error of the Invalid template file has been completely solved.


Magesolution hope this tutorial will helps you fix the issue: Magento blank page and Blank Admin Page On Magento 2.3 In Windows. If your site still does not work after trying the methods in this tutorial, free to CONTACT US, and we will definitely support you! Magesolution is one of the leading Magento 2 extensions and Magento 2 theme providers and magento 2 web development services in the world. With 14+ years of experience, we offer high-quality products and services, specifically eCommerce, Web, and Apps Development that will meet every simple to complex demand.

330 Total Views 2 Views Today