exception(s):Exception #0 (Magento\Framework\Exception\ValidatorException): Invalid template file

While running Magento 2.x & displaying Invalid template file error as below

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

Solution: There are following below steps need to follow

[1] – Find validateURLScheme function in below Path vendor\magento\framework\Image\Adapter\Gd2.php file. at line 96

[2] – Replace function with this: !file_exists($filename)

private function validateURLScheme(string $filename) : bool
{
	if(!file_exists($filename)) { // if file not exist
		$allowed_schemes = ['ftp', 'ftps', 'http', 'https'];
		$url = parse_url($filename);
		if ($url && isset($url['scheme']) && !in_array($url['scheme'], $allowed_schemes)) {
			return false;
		}
	}

	return true;
}

[3] – Finally Magento 2.x Invalid template issue will be resolved & site will be run properly.

Leave a Reply

Your email address will not be published. Required fields are marked *