I have upgraded 2.2.6 version to 2.2.7 version but its showing below error in my website.

1 exception(s):
Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/xampp2/htdocs/magento2/demo1/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'

Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file: 'C:/xampp2/htdocs/magento2/demo1/vendor/magento/module-theme/view/frontend/templates/page/js/require_js.phtml' in module: '' block's name: 'require.js'
#0 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\View\Element\Template.php(300): Magento\Framework\View\Element\Template->fetchView('C:/xampp2/htdoc...')
#1 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\View\Element\AbstractBlock.php(667): Magento\Framework\View\Element\Template->_toHtml()
#2 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\View\Result\Page.php(248): Magento\Framework\View\Element\AbstractBlock->toHtml()
#3 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\View\Result\Layout.php(170): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor))
#4 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\Interception\Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#5 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\Interception\Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array)
#6 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\Interception\Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception\{closure}(Object(Magento\Framework\App\Response\Http\Interceptor))
#7 C:\xampp2\htdocs\magento2\demo1\generated\code\Magento\Framework\View\Result\Page\Interceptor.php(130): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array)
#8 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\App\Http.php(139): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor))
#9 C:\xampp2\htdocs\magento2\demo1\generated\code\Magento\Framework\App\Http\Interceptor.php(24): Magento\Framework\App\Http->launch()
#10 C:\xampp2\htdocs\magento2\demo1\vendor\magento\framework\App\Bootstrap.php(257): Magento\Framework\App\Http\Interceptor->launch()
#11 C:\xampp2\htdocs\magento2\demo1\index.php(39): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor))
#12 {main}

Same issue i am facing if i upgrade website from 2.6 to 2.3.

Is there any solution?


if your magento installation is running on windows than in magento's some versions like in 2.2.7 we have to replace the code of file vendor/magento/framework/view/element/template/file/validator.php with this.

protected function isPathInDirectories($path, $directories)
    $realPath = str_replace('\\', '/', $this->fileDriver->getRealPath($path));
    if (!is_array($directories)) {
        $directories = (array)$directories;

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

and now reload the magento application.

  • 2
    Worked perfectly. Thanks alot. +1 Apr 8 '19 at 16:41
  • 2
    thanks alot, you save my day. +1 Apr 25 '19 at 4:05
  • 1
    It works in xampp thanks a lot...
    – John
    Apr 7 '20 at 4:55
  • 1
    Its worked. Thank you. May 3 '20 at 16:50
  • 1
    It worked for me! Thanks a lot. Aug 10 '20 at 10:04

This should be only a problem of your local installation, because your Magento instance is running on Windows.

So this could be a temporary fix in vendor\magento\framework\View\Element\Template\File\Validator.php

Go to line number 114 and change the line number and replace below line

$filename = str_replace('\\', '/', $filename);


$filename = str_replace('\\', '/', $this->fileDriver->getRealPath($filename));
  • Hello @tho, i have applied this solution and now website is loading but home page and admin login shows blank page. Dec 4 '18 at 3:54
  • 1
    Thanks mate. worked for me. +1 Apr 8 '19 at 16:42

I had this problem in my case it was a module that I used in the registration.php file

    isset($file) ? dirname($file) : __DIR__

the problem is in this line "isset ($ file)? dirname ($ file): __DIR__" so I changed it to "__DIR__", and now it works, I hope it helps.

  • Had the same issue with a module of a colleague. Wasted so much time to find the reason for the problem. I'm glad to found your answer. Probably he introduced this by this hackish solution.
    – robsch
    Aug 3 '20 at 15:18

I got the same error on linux. If you are running Magento in developer mode, this may happen because Magento does not understand symlinks. To allow symlinks, simply execute the following sql:

update `core_config_data` set `value`='1' where `path`='dev/template/allow_symlink';

Then run: bin/magento cache:flush

  • This was super helpful and worked for me after importing a production-mode database into a developer-mode environment. Thank you!
    – Mike Dubs
    Apr 12 '21 at 20:19

For Upgrade Magento 2.2.6 to Magento 2.3.0 without any issue, I have just upgrade one of our ongoing projects from Magento 2.2.6 to 2.3.0 and nothing break the functionality of the ongoing project.

you can easily upgrade using Magento command line,

You need to follow four steps to upgrade from older version to latest version Magento 2.3

For upgrade to Magento 2.3 You must require PHP 7.1.3+ or PHP 7.2.

You can't simply upgrade using Composer update command only.

Hope you will be helpful above steps.

  • Hello @Rakesh, i am using php version 7.1.7 and applied Mr. tho solution and website is not showing any error. my store is in development mode. but showing blank page. Dec 4 '18 at 6:17

I know it's quite old problem and everyone already knows the solution, but I created quick composer-based package with fix, just run in your Magento root:

composer require idealcode/magento2-windows-compatibility

I hope it will be useful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.