Help with Warning & Fatal Error


I've uploaded a php script and see this on a particular php page:

Warning: require_once(vendor/autoload.php): failed to open stream: No such file or directory in /home/public_html/../config.php on line 2

Fatal error: require_once(): Failed opening required 'vendor/autoload.php' (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home//public_html/.../config.php on line 2

config.php has this:

require_once 'vendor/autoload.php';

$dotenv = new Dotenv\Dotenv(__DIR__);

foreach($_ENV as $key => $val) {
  define($key, $val);

I'm not clear on why the warning and error are appearing.
Can you shed some light on what it means and how I might remedy this Warning and Error?



Check the file permission on that folder. Make sure that the server can access that file. Usually this error is one or the other. Either the file doesn't exist or the file doesn't have the right permissions.


Thanks for your reply.
I changed the permission to 777 on the folder and on the file in question and on the config.php file,
cleared the cache, but nothing has changed. Any other ideas will be appreciated.


Check that the config.php is actually located where you expect it to be located


Just like @SpacePhoenix is saying. The first thing you do is check if that file is in the correct place first. Then you check the file permission. If both of those don't change a thing, include the full path in your require statement.


Which is always a good thing. Including relative paths is a disaster waiting to happen.

Something like include (__DIR__.'/vendor/autoload.php); would be lot better.


This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.