Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Magento 2安装后出现无效模板异常_Magento_Exception_Admin_Magento2 - Fatal编程技术网

Magento 2安装后出现无效模板异常

Magento 2安装后出现无效模板异常,magento,exception,admin,magento2,Magento,Exception,Admin,Magento2,我今天在本地主机上安装了Magento 2.0平台。在完成所有的设置和安装之后,当我试图打开管理面板时,它显示了一个棕色的空白屏幕。当我切换到开发人员模式时,它显示require_js.phtml的一个无效模板错误。完全错误是: 1 exception(s): Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/xampp/htdocs/magento_demo/ven

我今天在本地主机上安装了Magento 2.0平台。在完成所有的设置和安装之后,当我试图打开管理面板时,它显示了一个棕色的空白屏幕。当我切换到开发人员模式时,它显示require_js.phtml的一个无效模板错误。完全错误是:

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/xampp/htdocs/magento_demo/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_demo/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_demo\vendor\magento\framework\View\Element\Template.php(301): Magento\Framework\View\Element\Template->fetchView('C:/xampp/htdocs...')
#1 C:\xampp\htdocs\magento_demo\vendor\magento\framework\View\Element\AbstractBlock.php(668): Magento\Framework\View\Element\Template->_toHtml()
#2 C:\xampp\htdocs\magento_demo\vendor\magento\framework\View\Result\Page.php(249): Magento\Framework\View\Element\AbstractBlock->toHtml()
#3 C:\xampp\htdocs\magento_demo\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_demo\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_demo\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_demo\generated\code\Magento\Framework\App\Http\Interceptor.php(24): Magento\Framework\App\Http->launch()
#7 C:\xampp\htdocs\magento_demo\vendor\magento\framework\App\Bootstrap.php(258): Magento\Framework\App\Http\Interceptor->launch()
#8 C:\xampp\htdocs\magento_demo\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#9 {main}

我以前从未使用过Magento,不知道问题是什么,也不知道如何解决。有人能告诉我如何解决这个问题吗?

您可以从项目根目录执行composer update,它将更新所有缺少的依赖项

除此之外,您还可以刷新Magento缓存并重新部署静态内容,请执行以下步骤:

1) php bin/magento cache:flush or (sudo rm -rf <magento-root>/var/generated/* <magento-root>/pub/static/*)
2) php bin/magento setup:static-content:deploy
1)php bin/magento缓存:刷新或(sudo rm-rf/var/generated/*/pub/static/*)
2) php bin/magento设置:静态内容:部署

现在清理浏览器缓存并重新加载页面。

是的,这就是windows的问题所在。Windows使用“”作为分隔符,数组“目录”包含以“/”作为分隔符的条目,因此检查将始终失败。因此,您需要通过替换核心文件中的分隔符来解决此问题:

Magento\Framework\View\Element\Template\File\Validator
函数isPathInDirectories替换isPathInDirectories函数中的以下代码

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

composer安装
为我做的,谢谢。