Skip to main content

How to fix the «Invalid template file» / «require_js.phtml» failure of Magento 2.3.x in Windows?

go to this file


/Magento/Framework/View/Element/Template/File/Validator.php

replace this part


foreach ($directories as $directory) {
    if (0 === strpos($realPath, $directory)) {

with the following one:

$isWin = 'WIN' === strtoupper(substr(PHP_OS, 0, 3)); 

/** @var bool $isWin */ 
foreach ($directories as $directory) { 
    if (0 === strpos($realPath, !$isWin ? $directory : $this->fileDriver->getRealPath($directory)) ) {

 

Original article 

https://mage2.pro/t/topic/5774

Tags