How To Resolve Blank Page Error [Storefront & Backend] After Installation in Magento 2.x

While Installing a Magento 2.x installation [Community Edition or Enterprise Edition or Commerce Cloud Edition ], you have seen that common blank page error [Storefront & Backend] that displays blank page.

Solution :: The following below steps need to follow

Step [1] – Go To ‘Validator.php’ file located at below path,

File Path = Magento 2 Root Directory
\vendor\magento\framework\View\Element\Template\File\Validator.php

Step [2] – Once open Validator.php

protected function isPathInDirectories($path, $directories)
{
    if (!is_array($directories)) {
        $directories = (array)$directories;
    }
    foreach ($directories as $directory) {
        if (0 === strpos($this->fileDriver->getRealPath($path), $directory)) {
            return true;
        }
    }
    return false;
}

[3] – Need to replace Validator.php code with following below code

protected function isPathInDirectories($path, $directories) {

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

if (!is_array($directories)) 

{ $directories = (array)$directories; } 

foreach ($directories as $directory) { 

if (0 === strpos($realPath, $directory)) 

{ return true; } 

} return false; 

}


Leave a Reply

Your email address will not be published. Required fields are marked *