6

just moved over my laravel site to my live server and straight away faced with this error.

The complete error is:

Warning: require(/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/../vendor/autoload.php' (include_path='.:/usr/local/lib/php') in /var/sites/b/beta.buildsanctuary.com/public_html/local/bootstrap/autoload.php on line 17

The line 17 is:

require DIR.'/../vendor/autoload.php';

Folder structure is:

beta.buildsanctuary.com
  -- public_html
  -- subdomains
    -- beta
      -- local
        -- bootstrap
        -- vendor

Any help where this is going wrong? And how to fix? Pulling my hair out trying all sorts of paths.

Thanks, Craig.

3

6 Answers 6

14

I strongly believe that a corrupted cache was the cause, I cannot be 100% sure but it seem that it is likely the culprit.

So, if anyone comes across a similar problem, I would suggest the following steps:

  1. Delete the vendor folder
  2. Delete composer.lock
  3. Run the command composer clearcache (or clear-cache)
  4. Run composer install

I hope this can help somebody.

1
  • 1
    I was running on composer version 1 and after ran composer selfupdate I got version 2 which was able to fix the issue. Commented Jun 8, 2021 at 13:43
4

As you can see from the error, PHP is looking for

public_html/local/bootstrap/../vendor/autoload.php`

which is

public_html/local/vendor/autoload.php

That folder does not exist. I think the folder structure you posted is wrong.

Anyway, try this:

require('../vendor/autoload.php');
1
  • Same error but just with the changed path. Have read somewhere its to do with composer not being installed correctly on my live server etc. Shall look into that route.
    – Lovelock
    Commented Nov 7, 2014 at 22:56
2

I've had the same problem and it was that Composer was not installed yet in the server, so the directories structure it creates on your project does not exist neither.

First you have to install composer on your server, follow the instructions for your system given at the composer project webpage, https://getcomposer.org/.

Next you have to go in a terminal or cmd to the base folder of your project.

There you can use the commandline composer init, wich will guide you to create your composer.json file into your project.

Once you have created your composer.json file, you have to execute the commandline composer install.

This commandline will create all the dependencies you have written on your composer.json, and also will create the folder structure so the code you require would find the proper path.

At last, you have to reference the redirection to the folder vendor depending on the current folder structure location of your php file.

If you look for information, http://www.phptherightway.com/ was really helpfull.

2

Just run the following command, it will automatically install necessary dependencies:

composer install

2
  • run composer from which directory?
    – iewebguy
    Commented Aug 26, 2016 at 20:33
  • @iewebguy in the project root directory Commented Jun 8, 2021 at 11:52
0

try disable extension=sockets in php.ini

1
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Nov 19, 2023 at 15:07
-2

I had the same problem when I have had migrated a drupal website to new server... To solve the problem I just used the composer command:

  1. First cd into website directory, EX: cd /var/www/your_website

  2. Run composer to install drupal 8 dependencies that it's need in the website directory;

composer install

If you use the sudo command, make sure the .../vendor directory has the right permission to be accessed by the user who in the /var/wwwdirectory;

sudo composer install

This basically will solve the .../public_html/autoload.php on line 14 issue!

2
  • 1
    It is not advised to run composer as sudo Commented Jun 3, 2020 at 6:47
  • Like @BAKARISHEGHEMBE commented. You don't want to run Composer as sudo. There are certain composer commands that can execute code. Those scripts have full access to your account. Unless you look in detail at every package you install with Composer, don't do it. Commented Aug 30 at 14:28

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.