require(): Failed opening required '../vendor/autoload.php' (include_path='.:/usr/share/php')

Viewed 4373

I know, this question has been asked many times, but it seems the problem is different or I am missing something.

I have the following structure: /var/www/html/website/class/useofautoload.php

The vendor folder is at: /var/www/html/website/vendor and it has necessary folders and autoload.php file.

Things checked:

  1. Failed opening required '../vendor/autoload.php'
  2. Have relative path
  3. done: composer install
  4. done: composer update

Still, I don't know why I am getting this error.

Note: I have installed the composer at using sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer, will it create a problem as such?

I am using Amazon LightSail with only Ubuntu and no added stacks.

2 Answers

I've faced this error on my server working with Symfony 4. In my case, it was just a matter of absolute path :

require '../../vendor/autoload.php

to

require __DIR__.'/../../vendor/autoload.php

In fact, I've remarked that it was used the same way in the framework.

It seems that you did not make a correct relative path. try: ../../vendor/autoload.php.

Related