【问题标题】:Magento error Class ../validator does not existMagento 错误类 ../validator 不存在
【发布时间】:2019-05-05 03:36:42
【问题描述】:

我刚刚安装了 Magento2 平台。管理页面是空白的,显示没有任何内容的灰屏。我启用了显示错误,然后显示此错误,但我没有找到任何解决方案或原因:

处理您的请求时出错

类 Magento\Framework\View\Element\Template\File\Validator 没有 存在

【问题讨论】:

  • 你检查文件是否存在?
  • 是的,实际上我只是将这段代码添加到它以启用显示错误详细信息我也尝试删除它但仍然相同的错误 foreach ($directories as $directory) { // 添加此行 $realDirectory = $this->fileDriver->getRealPath($directory); // 并将$directory 替换为$realDirectory if (0 === strpos($realPath, $realDirectory)) { return true; }

标签: php magento e-commerce magento2


【解决方案1】:

检查以下路径。如果您的 magento 管理页面为空白,请检查路径: magento_root_dir\vendor\magento\framework\View\Element\Template\File\Validator.php

并更改以下行:

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

到:

if (0 === strpos($path, $directory)) {
     return true;
}

如果仍然无法找到该文件夹​​,请检查以下路径: magento_root_dir\lib\internal\Magento\Framework\View\Element\Template\File\Validator.php

【讨论】:

    【解决方案2】:

    您要安装的 Magento2 版本是什么?

    您能否将模式设置为开发人员并将 var/log/system.log 上的跟踪发送给我?

    查看如何设置 Magento2 模式 here

    谢谢

    【讨论】:

    • 我使用的是 Magento2 版本 2.3.0 我已经重新安装了它,错误是一样的(显示空白管理页面)。将其转换为开发人员模式并显示此错误:1 个异常:异常 #0 (Magento\Framework\Exception\ValidatorException):无效的模板文件:'C:/xampp/htdocs/mymagento/vendor/magento/module-backend /view/adminhtml/templates/page/js/require_js.phtml' in module: 'Magento_Backend' block's name: 'require.js' with some other lines....
    • 您是否尝试找到此 mymagento/vendor/magento/module-backend/view/adminhtml/templates/page/js/require_js.phtm ?它存在吗?
    • 其实我把整个项目都删了,重新安装一遍。错误不再出现在我面前。我要感谢您并感谢您对帮助的兴趣。因为我没有找到从这里删除问题的方法所以它仍然在这里。
    【解决方案3】:

    Magento 2 在生成的文件夹中生成工厂类。如果生成的文件夹具有文件写入权限或所有权权限,则无法生成工厂类。对于 Magento 2,generated 文件夹位于 magento 根路径中。

    运行以下命令并尝试:

    chmod -R 777 generated/ var/
    chown -R magento_user:magento_user generated/`
    

    【讨论】:

      猜你喜欢
      • 2022-11-02
      • 1970-01-01
      • 2019-01-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-20
      • 2023-02-03
      • 2023-01-10
      相关资源
      最近更新 更多