【问题标题】:Blank admin page on Magento 2.3.0 CE in localhost本地主机中 Magento 2.3.0 CE 上的空白管理页面
【发布时间】:2019-05-02 06:36:26
【问题描述】:

我已经在本地机器上安装了 Magento 2.3,安装正常。我可以通过localhost/magento 访问我的商店。我试图访问我的管理页面localhost/magento/admin_pogi,但它给了我一个空白页面并重定向到网址http://localhost/magento/admin_pogi/admin/index/index/key/a062e79f617010c42b07d662103d5142cd9bbe86314fb54da3e4cb5542b11eee/

到目前为止我尝试的是启用开发模式,我在我的管理页面上看到了这个错误:

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid 
template file: 'C:/xampp/htdocs/magento/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: 'C:/xampp/htdocs/magento/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtml' in module: 'Magento_Backend' block's name: 'require.js'
#0 C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\Template.php(301): 
Magento\Framework\View\Element\Template->fetchView('C:/xampp/htdocs...')
#1 C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()#2 
C:\xampp\htdocs\magento\vendor\magento\framework\View\Result\Page.php(249): 
Magento\Framework\View\Element\AbstractBlock->toHtml()
#3 
C:\xampp\htdocs\magento\vendor\magento\framework\View\Result\Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#4 C:\xampp\htdocs\magento\generated\code\Magento\Backend\Model\View\Result\Page\Interceptor.php(193): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#5 C:\xampp\htdocs\magento\vendor\magento\framework\App\Http.php(139): Magento\Backend\Model\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#6 C:\xampp\htdocs\magento\generated\code\Magento\Framework\App\Http\Interceptor.php(24): Magento\Framework\App\Http->launch()
#7 C:\xampp\htdocs\magento\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()
#8 C:\xampp\htdocs\magento\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#9 {main}

【问题讨论】:

    标签: javascript php magento xampp magento2


    【解决方案1】:

    这将是一个解决this commit 的错误。作者将$path改为

    $this->fileDriver->getRealPath($path)
    

    这只是在$path 上调用realpath(),但这可能会更改以前受其影响的$path 上的目录分隔符

    #/vendor/magento/framework/View/Element/Template/File/Validator.php:114
    $filename = str_replace('\\', '/', $filename);
    

    在 Windows 操作系统上,这将恢复以上 str_replace 的更改,以便像这样的路径

    D:/Magento2.3/vendor/magento
    

    将规范化为其 Windows 特定版本:

    D:\Magento2.3\vendor\magento
    

    这不会导致在 Magento\Framework\View\Element\Template\File\Validator 类的 isPathInDirectories() 方法中成功比较:

    foreach ($directories as $directory) {
        if (0 === strpos($realPath, $directory)) {
            return true;
        }
    }
    

    解决方案

    目前我们可以在上面的 foreach 循环中进行快速更改,以便我们可以运行我们的 magento 而不会出现进一步的问题:

    #/vendor/magento/framework/View/Element/Template/File/Validator.php:139
    foreach ($directories as $directory) {
        // Add this line
        $realDirectory = $this->fileDriver->getRealPath($directory);
        // and replace `$directory` with `$realDirectory`
        if (0 === strpos($realPath, $realDirectory)) {
            return true;
        }
    }
    

    【讨论】:

    • 谢谢。所以你的意思是2.3.0不是一个稳定的版本?如果是,您会为我推荐什么版本?先生,我有很多关于 magento 的问题。我是 magento 的新手。我可以问你更多问题吗?如果可以的话,我在哪里可以联系到你?谢谢先生!你救了我一整天!!!!
    • 不客气。 v2.2.6 目前可能是更好的选择。我也是 v2 的新手,所以我不能很好地参与其中。
    • 10 天了,他们仍然没有发布任何小的增量更新来修复这个明显的错误。好难过……
    • @revo,你能提供修复以在本地覆盖它吗?
    • @GhostCat 我很高兴听到这个消息!
    【解决方案2】:

    步骤 01。 进入这个目录 C:\xampp\htdocs\magento\vendor\magento\framework\View\Element\Template\File

    步骤 02。 打开文件验证器.php 注释行 139($realPath = $this->fileDriver->getRealPath($path);) 添加此代码

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

    还有一些时间管理页面加载但不加载 css 那么如何解决这个问题

    步骤_01 转到此目录 app/etc/di.xml

    步骤 02 找到这一行

    <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\Symlink</item>
    

    步骤 03 像下面这样改变

    <item name="view_preprocessed" xsi:type="object">Magento\Framework\App\View\Asset\MaterializationStrategy\copy</item>
    

    而且有时候主页加载不正确,如何解决

    步骤 01 进入这个目录 变量/缓存

    步骤 02 删除缓存文件并刷新页面

    【讨论】:

    • 管理页面需要多次刷新,但它终于开始工作了:D
    • 这对我有用!
    【解决方案3】:

    这是 Magento 2.3.0 的核心问题。 要解决此问题,您必须更改 Magento 核心文件中的代码。

    转到路径/vendor/magento/framework/View/Element/Template/File/Validator.php在这个文件中找到:

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

    替换为:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-11-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-12-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多