Sharing some useful tips, solutions and notes for Geeks.

Wednesday, August 10, 2016

Autoload error in Magento




When we have a wordpress or other sites in document root of Magento, we might get some warning like this:
Warning: include(file.php): failed to open stream: No such file or directory in /lib/Varien/Autoload.php on line 93

This is because Autoloader tries to map php class name to file and tries to include the file.
The code is like return include $classFile;

We can overide this warning by checking the file using stream_resolve_include_path function. So the modified code will be

if (stream_resolve_include_path($classFile)) {
            return include $classFile;
        } else {
            return false;
        } 

After this the warning message no longer shows in log. Hope this helps. :)

4 comments:

Muthukrishnan N said...

Wow really usefull post, this is what I was searching on google!!!, thanks alot

Unknown said...

Really Nice post. Was useful for many.

Unknown said...

Wonderful post.

Muthukrishnan N said...

Is this work on Magento 2 too ?