Home » Laravel, PHP24 October 2016

[SOLVED] Laravel Error: Failed to open stream: No such file or directory bootstrap/autoload.php

You might get the following error while trying to run Laravel for the first time.

Warning: require(/var/www/laravel/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/laravel/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required ‘/var/www/laravel/bootstrap/../vendor/autoload.php’ (include_path=’.:/usr/share/php:/usr/share/pear’) in /var/www/laravel/bootstrap/autoload.php on line 17

Problem Scenario:

This error generally occurs when you download/clone Laravel from Github and then you put it in your web server. Then, you try to access it through your browser (e.g. http://localhost/laravel/public).

Cause:

Though you have downloaded the Laravel code and put it in your server, there’s still missing dependencies (library files/codes) in the code. The missing dependencies should be installed in order to make Laravel run properly.

Solution:

To solve this error, you need to install the missing dependencies via composer. Composer is a dependency manager tool for PHP. If you don’t have composer installed in your system then you need to install it first. You can get/download composer from here: https://getcomposer.org.

Once you have installed composer on your system/computer, then you need to follow the steps below to install the missing dependencies:

– Open terminal or command prompt
– Go to your Laravel directory
– For example, in Ubuntu Linux the web root is /var/www/, in Windows if you install Wampp in C: Drive then the web root will be C://wampp/www
– Suppose, you downloaded and copied the Laravel files in directory named ‘laravel’
– Then, your Laravel directory on your web server in Ubuntu will be /var/www/laravel
– You can go to that directory by running the following command on terminal: cd /var/www/laravel
– Run the following command

– This will install the required dependencies to run Laravel. It will take some time to install all the dependencies.
– Now, you should be able to access Laravel properly without any error, e.g. http://localhost/laravel/public

If you already have run composer install command and still getting the error, then you can try running the following command:

Note: If you are on Linux then you should also set write permission to bootstrap/cache and storage directories.

Here’s the command to do so:

Alternatively, the better way to create laravel project / install Laravel will be directly through composer. Instead of downloading/cloning Laravel from GitHub, you can run the following composer command in terminal/command-prompt:

– Go to your web server root (in Ubuntu, it’s /var/www/)
– Run the following command in terminal:

– This will create a directory with name-of-your-project and install Laravel files in it
– This will also install all the required dependencies to run Laravel
– Then, you can simply browse http://localhost/name-of-your-project/public to access Laravel

Hope this helps. Thanks.

PHP

Get New Post by Email

Find me on

FacebookTwitterGoogle+LinkedInRSS Feed