Magento installation admin blank screen

magento admin blank screen issues

Resolving Magento Admin Black Screen Issue

 

If you are encountering a black screen issue in the Magento admin panel, it might be due to a path handling problem. A simple change in the isPathInDirectories function can help resolve this issue. Follow the steps below to implement the solution.

Step-by-Step Guide:

  1. Locate the Function: Find the isPathInDirectories function in your Magento codebase. It should look something like this:
    protected function isPathInDirectories($path, $directories)
    {
        if (!is_array($directories)) {
            $directories = (array)$directories;
        }
        $realPath = $this->fileDriver->getRealPath($path);
        foreach ($directories as $directory) {
            if ($directory !== null && 0 === strpos($realPath, $directory)) {
                return true;
            }
        }
        return false;
    }
    
  2. Modify the Code: Replace the line:
    $realPath = $this->fileDriver->getRealPath($path);
    with:
    $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
    The updated function should look like this:
    protected function isPathInDirectories($path, $directories)
    {
        if (!is_array($directories)) {
            $directories = (array)$directories;
        }
        $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
        foreach ($directories as $directory) {
            if ($directory !== null && 0 === strpos($realPath, $directory)) {
                return true;
            }
        }
        return false;
    }
    
  3. Save and Test: Save the changes and refresh your Magento admin panel. The black screen issue should now be resolved.

Explanation:

The problem arises because paths with backslashes (\) might not be recognized correctly, especially in environments where forward slashes (/) are expected. By replacing backslashes with forward slashes, the paths are normalized, ensuring they are handled correctly across different systems.

Leave a Reply

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