在Windows 10上安装Magento 2.3后空白的管理页面 [英] Blank admin page after installing Magento 2.3 on Windows 10

查看:201
本文介绍了在Windows 10上安装Magento 2.3后空白的管理页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用xampp在Windows 10上本地安装Magento 2.3.我从Github下载了压缩文件,解压缩到c:\xampp\htdocs\magento2,然后在浏览器中从localhost/magento2/setup运行安装程序.

I am installing Magento 2.3 locally on Windows 10 with xampp. I downloaded the archive from Github, unzipped to c:\xampp\htdocs\magento2, and ran the installer from localhost/magento2/setup in my browser.

安装程序没有任何错误,但是,当我进入管理页面时,我得到了一个带有灰色背景的空白页面.当我去localhost/magento2时,我得到了

The installer finished with no errors, however when I go to the admin page, I get a blank page with a grayish background. When I go to localhost/magento2, I get this

当我查看magento2/var/log/system.log时,会出现一些类似以下内容的错误(对于不同的文件名列表,这些错误中的每一个都会重复多次)

When I look in magento2/var/log/system.log, there are some errors that say stuff like the following (each of these errors is repeated several times for a list of different file names)

main.ERROR: A symlink for "C:/xampp/htdocs/magento2/lib/web/requirejs/require.js" can't be created and placed to "C:/xampp/htdocs/magento2/pub/static/adminhtml/Magento/backend/en_US/requirejs/require.js". Warning!symlink(): Cannot create symlink, error code(1314) [] [] ) [] []

main.ERROR: A symlink for "C:/xampp/htdocs/magento2/lib/web/requirejs/require.js" can't be created and placed to "C:/xampp/htdocs/magento2/pub/static/adminhtml/Magento/backend/en_US/requirejs/require.js". Warning!symlink(): Cannot create symlink, error code(1314) [] [] ) [] []

main.CRITICAL: Invalid template file: 'C:/xampp/htdocs/magento2/app/code/Magento/Backend/view/adminhtml/templates/page/js/require_js.phtml' in module: 'Magento_Backend' block's name: 'require.js' [] []

我通过更改magento\lib\internal\Magento\Framework\View\Element\Template\File\Validator.php

原始代码为

public function isValid($filename)
{
    $filename = str_replace('\\', '/', $filename);
    if (!isset($this->_templatesValidationResults[$filename])) {
        $this->_templatesValidationResults[$filename] =
            ($this->isPathInDirectories($filename, $this->_compiledDir)
                || $this->isPathInDirectories($filename, $this->moduleDirs)
                || $this->isPathInDirectories($filename, $this->_themesDir)
                || $this->_isAllowSymlinks)
            && $this->getRootDirectory()->isFile($this->getRootDirectory()->getRelativePath($filename));
    }
    return $this->_templatesValidationResults[$filename];
}

我将其更改为

public function isValid($filename)
{
   return true;
}

由于我是Magento的新手,所以我不知道该方法应该做什么(我假设它正在验证模板文件,但我不知道该怎么做或在哪里).此外,当我在原始代码中添加一个log语句以显示$this->_templatesValidationResults[$filename]的内容(在return语句之前)时,它打印了几个空数组元素.例如,它打印

Since I'm new to Magento, I don't understand what this method is supposed to be doing (I assume it's validating a template file, but I don't know how or where). Furthermore, when I added a log statement to the original code to show the contents of $this->_templatesValidationResults[$filename] (right before the return statement), it printed several empty array elements. For example, it printed

[] []  
[] []
[] []
[] []

Magento似乎认为模板文件无效,但是并没有给出它们无效的任何原因.我的说法是否正确?我该如何阻止Magento错误地将模板文件检测为无效文件,或者得到正确的验证错误消息?

It appears like Magento thinks the template files are invalid, but it doesn't give any reasons why they're invalid. Am I correct in saying this, and how would I either stop Magento from erroneously detecting the template files as invalid, or get the proper validation error message?

可能的解决方案和其他问题

我将问题追溯到文件magento\lib\internal\Magento\Framework\View\Element\Template\File\Validator.php

功能

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

问题是$path中包含正斜杠,但$realPath中具有反斜杠,因此strpos从不返回匹配项,并且该函数始终返回false.我将功能更新为

The problem is that $path has forward slashes in it, but $realPath has backslashes, so the strpos never returns a match, and the function always returns false. I updated the function to

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

现在它可以工作了.我认为这是仅Windows的问题?这是Magento中的错误,没有解决Windows文件命名问题吗?还是我在设置中做错了什么?

And now it works. I assume this is a Windows-only problem? Is this a bug in Magento that doesn't account for Windows file naming, or is there something I've done incorrectly in my setup?

推荐答案

我与Windows 10上的magento 2.3有相同的问题,后台页面显示空白背景为棕色背景.

I have same issue to with magento 2.3 on Windows 10, backoffice page show blank page with brown background.

在网络上搜索问题后,终于找到了解决方法

after searching the problem on the web, finally found solution

  1. 在magen中打开文件/vendor/magento/framework/View/Element/Template/File/Validator.php ,找到

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

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

替换为:

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

显示最终登录页面,但登录页面和登录后图标丢失

Finally login page showing, but the icon is missing in login page and after login

  1. 在magen中打开文件 app/etc/di.xml ,找到目录

Magento \ Framework \ App \ View \ Asset \ MaterializationStrategy \ Symlink

Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink

并替换为

Magento\Framework\App\View\Asset\MaterializationStrategy\Copy

  1. 然后转到 var/cache ,删除所有文件夹/文件
  2. 刷新页面,完成.
  1. Then go to var/cache , delete all folder / file
  2. refresh the page, done.

这篇关于在Windows 10上安装Magento 2.3后空白的管理页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆