cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.4.1 Use of undefined constant fileDriver

Magento 2.4.1 Use of undefined constant fileDriver

Magento installation error.

magento CE 2.4.1, PHP 7.4.16

 

{"0":"Warning: Use of undefined constant fileDriver - assumed 'fileDriver' (this will throw an Error in a future version of PHP) in C:\\xampp\\htdocs\\magento\\vendor\\magento\\framework\\View\\Element\\Template\\File\\Validator.php on line 138","1":"#1 Magento\\Framework\\View\\Element\\Template\\File\\Validator->isPathInDirectories('C:\/xampp\/htdocs\/...', array('C:\/xampp\/htdocs\/...')) called at [vendor\\magento\\framework\\View\\Element\\Template\\File\\Validator.php:117]\n#2 Magento\\Framework\\View\\Element\\Template\\File\\Validator->isValid('C:\/xampp\/htdocs\/...') called at [vendor\\magento\\framework\\View\\Element\\Template.php:270]\n#3 Magento\\Framework\\View\\Element\\Template->fetchView('C:\/xampp\/htdocs\/...') called at [vendor\\magento\\framework\\View\\Element\\Template.php:303]\n#4 Magento\\Framework\\View\\Element\\Template->_toHtml() called at [vendor\\magento\\framework\\View\\Element\\AbstractBlock.php:1111]\n#5 Magento\\Framework\\View\\Element\\AbstractBlock->Magento\\Framework\\View\\Element\\{closure}() called at [vendor\\magento\\framework\\View\\Element\\AbstractBlock.php:1115]\n#6 Magento\\Framework\\View\\Element\\AbstractBlock->_loadCache() called at [vendor\\magento\\framework\\View\\Element\\AbstractBlock.php:675]\n#7 Magento\\Framework\\View\\Element\\AbstractBlock->toHtml() called at [vendor\\magento\\framework\\View\\Result\\Page.php:249]\n#8 Magento\\Framework\\View\\Result\\Page->render(&Magento\\Framework\\App\\Response\\Http\\Interceptor#0000000039ace4df0000000073cb4111#) called at [vendor\\magento\\framework\\View\\Result\\Layout.php:171]\n#9 Magento\\Framework\\View\\Result\\Layout->renderResult(&Magento\\Framework\\App\\Response\\Http\\Interceptor#0000000039ace4df0000000073cb4111#) called at [generated\\code\\Magento\\Backend\\Model\\View\\Result\\Page\\Interceptor.php:140]\n#10 Magento\\Backend\\Model\\View\\Result\\Page\\Interceptor->renderResult(&Magento\\Framework\\App\\Response\\Http\\Interceptor#0000000039ace4df0000000073cb4111#) called at [vendor\\magento\\framework\\App\\Http.php:120]\n#11 Magento\\Framework\\App\\Http->launch() called at [generated\\code\\Magento\\Framework\\App\\Http\\Interceptor.php:23]\n#12 Magento\\Framework\\App\\Http\\Interceptor->launch() called at [vendor\\magento\\framework\\App\\Bootstrap.php:263]\n#13 Magento\\Framework\\App\\Bootstrap->run(&Magento\\Framework\\App\\Http\\Interceptor#0000000039ace4d00000000073cb4111#) called at [index.php:39]\n","url":"\/magento\/admin_1omwyo\/admin\/index\/index\/key\/45b79d398d8a3c6a81c25a1363c6b59cacd9406e5d0f9df0700e4d62fcf6fb8a\/","script_name":"\/magento\/index.php","report_id":"95817de3c05067e354f6a8bab97b475dd3a2fbcfd63c94b96c8c28c1defbc19a"}

 

 

Can anyone Help ?

1 REPLY 1

Re: Magento 2.4.1 Use of undefined constant fileDriver

Hello @myst1067

Yes, This is the problem with windows. Windows uses "\" as separator, the array "directories" contains entries with "/" as separator, so the check will always fail. So you need to fix this by replacing the separator in core file:

Magento\Framework\View\Element\Template\File\Validator

function isPathInDirectories replace below code in isPathInDirectories function

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