4

enter image description here I have installed magento 2.3 latest version, But I never login in admin panel.

2

4 Answers 4

9

I am new to magento, I faced the same problem and found the follwoing solution:

Magento 2.3.1 File Location:

xampp/htdocs/vendor/magento/framework/View/Element/Template/File/Validator.php

Code:

public function isValid($filename)
{
    $filename = str_replace('\\', '/', $filename);
    if (!isset($this->_templatesValidationResults[$filename])) {
        $this->_templatesValidationResults[$filename] =
            ($this->isPathInDirectories($filename, $this->_compiledDir)
                || $this->isPathInDirectories($filename, $this->moduleDirs)
                || $this->isPathInDirectories($filename, $this->_themesDir)
                || $this->_isAllowSymlinks)
            && $this->getRootDirectory()->isFile($this->getRootDirectory()->getRelativePath($filename));
    }
    return $this->_templatesValidationResults[$filename];
}

To Replace with this simple code:

public function isValid($filename)
{
   return true;
}

It works for me and hope will work for someone like me.

3
  • Good its worked for me. Thanks. But, Is it make any trouble infuture on any work? Commented May 29, 2019 at 4:27
  • THanks man, you saved a day!
    – KTM
    Commented May 2, 2020 at 10:36
  • Worked for me. Nice answer.
    – Pupil
    Commented May 14, 2020 at 16:23
4

This is Magento bug. Wrong paths to Windows are generated. The fixed fix is

Magento 2.3.0

#/vendor/magento/framework/View/Element/Template/File/Validator.php:114

the string

$realPath = $this->fileDriver->getRealPath($path);

to replace

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

Magento 2.2.7

/vendor/magento/framework/View/Element/Template/File/Validator.php:113

code

protected function isPathInDirectories($path, $directories)
{
    if (!is_array($directories)) {
        $directories = (array)$directories;
    }
    foreach ($directories as $directory) {
        if (0 === strpos($this->fileDriver->getRealPath($path), $directory)) {
            return true;
        }
    }
    return false;
}

to replace

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;
    }
4

Go to /vendor/magento/framework/View/Element/Template/File/Validator.php then find this code

$realPath = $this->fileDriver->getRealPath($path);

Now replace it with the below code.

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

Try to delete files and folder from following location :

rm -rf root/pub/static/adminhtml root/pub/static/frontend root/pub/static/deployed_version.txt
  • Give proper permission to static folder
  • Run following command :

    bin/magento setup:upgrade bin/magento setup:di:compile bin/magento setup:static-content:deploy

May be issue is static file are not deployed properly , above step will regenerate static files . Thanks

1
  • There are some situation , when templates are not generated fully , and cause blank page issue , at least I faced this issue , So with due respect, may I know your opinion why you did negative vote , could you justify your verdict . Thanks Commented Aug 13, 2019 at 9:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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