400

I have recently installed Laravel 5 via Composer. I tried creating a new controller using Artisan and got the following error. Am I missing something?

bootstrap/../vendor/autoload.php. Failed to open stream: No such file or directory. The "vendor" folder does not exist.

Karl Hill
  • 12,937
  • 5
  • 58
  • 95
Scott
  • 5,074
  • 3
  • 16
  • 13

30 Answers30

334

Run composer with --no-scripts

composer update --no-scripts  

This shall fix the issue. I tried this on Mac and Linux.

Shubhamoy
  • 3,718
  • 2
  • 19
  • 24
  • 17
    Sometimes when you run: "composer install" you got that error too, so the best option is first run: "composer install --no-scripts" and then run composer install normally. – manuelpgs Apr 04 '16 at 13:39
  • 5
    Composer documentation: --no-scripts: Skips execution of scripts defined in composer.json. (https://getcomposer.org/doc/03-cli.md#update) – Aine Jul 07 '16 at 09:23
  • It's much better to use composer install, because it will run everything necessary to install all dependencies, including scripts. – Leandro Jacques Mar 14 '17 at 13:37
  • error Composer could not find a composer.json file in C:\composer To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section – PHPFan Jan 03 '18 at 08:26
  • 1
    `composer install` was not working for me, `composer update --no-scripts` did the job. Thanks! – endo64 Feb 07 '18 at 15:16
  • Please Now I get: Sorry, the page you are looking for could not be found. After Run the command composer update --no-scripts. Also it tooks a lot time. – Fernando Pie Sep 24 '19 at 04:29
141

Which OS you are using ? For Windows : Go to Command Prompt

set path to www/{ur project}

For me : www/laravel5

Then type this command : composer install

It will automatically install all dependency in vendor/

Brane
  • 3,257
  • 2
  • 42
  • 53
MONTS_MIND_Hacker
  • 1,727
  • 2
  • 9
  • 9
103

Run composer install in your root project folder (or php composer.phar install).

dan-klasson
  • 13,734
  • 14
  • 63
  • 101
91

Turns out I didn't enable openssl in my php.ini so when I created my new project with composer it was installed from source. I changed that and ran

composer update

now the vendor folder was created.

Scott
  • 5,074
  • 3
  • 16
  • 13
58

Did you create a new project or did you clone an existing project?

If you cloned an existing project it's very important to run

composer install

That way all the dependencies that are missing will be installed.

But if you create a new project you should run this command to make a new project using composer

composer create-project laravel/laravel name-of-your-project
Community
  • 1
  • 1
Dimitri Acosta
  • 1,756
  • 12
  • 15
24

I encountered the same problem. It occurred because composer was not able to install the dependencies specified in composer.json file. try running

composer install 

If this does not solve the problem, make sure the following php modules are installed php-mbstring php-dom

To install this extensions run the following in terminal

sudo apt-get install php-mbstring php-dom

once the installation is complete

try running the command in your project root folder

composer install 
Naved Deshmukh
  • 528
  • 7
  • 20
23

You need to regenerate autoload.php file. you can use dump-autoload to do that without having to go through an install or update.

use

composer dump-autoload

to generate autoload.php file again in /vendor directory.

Hamid Parchami
  • 7,319
  • 2
  • 18
  • 22
21

Following this below step solved my problem. You may try

composer update --no-scripts 
composer update
RASEL RANA
  • 2,112
  • 1
  • 15
  • 17
20

Just run this inside the directory where you installed your project

composer install
Williem
  • 1,131
  • 1
  • 12
  • 19
  • 1
    I did this and it worked, but why? I'd like to understand the reason please. – Simon Suh Oct 22 '16 at 17:52
  • 1
    @SimonSuh for some reason (network failure, new project was created without going through all commands, error during manual install, custom build install...) composer dependencies where no installed or are not up to date. this command will install and update all dependencies of your project and that will fix the issue. hope it is enought – Williem Oct 24 '16 at 02:18
20

After checking php version and a lot of research , the problem was on Composer side so just run the following command

composer install --ignore-platform-reqs

Brane
  • 3,257
  • 2
  • 42
  • 53
Hashmat Waziri
  • 476
  • 9
  • 9
8

This solution worked for me. The reason is not to have a vendor folder in your application.

Follow these steps:

  1. if your project has composer.json file, delete it

  2. then run

    composer require phpspec/phpspec
    

That command add vendor folder to your project

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Jayani Sumudini
  • 1,409
  • 2
  • 22
  • 29
7

go to your project folder via cmd. run the following command

composer update

it will install the missing vendor folder and files in your project.

but in some cases, it gives an error like "Your configuration does not allow connection to ....." in cmd.

for that go to your composer.json file,

change "secure-http": true to "secure-http": false

but in some cases (as was in my case) you may not find such line in your file. for that do the following action:

change "config": {
        "preferred-install": "dist"
}

to

"config": {
    "preferred-install": "dist",
    "secure-http": false
}

and run again composer update command.

hope this will solve problem.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
saadk
  • 1,243
  • 14
  • 18
6

Just run the following commands,

composer update

Or

composer install
Raham
  • 4,781
  • 3
  • 24
  • 27
6

When the new project created the laravel require to load vendors to autoload the libraries , We use composer update to

composer update

Composer is a dependency manager allows you to delegate responsibility for managing your dependencies to a third party.

5

Just setup a new project using composer instead of laravel like this:

composer create-project --prefer-dist laravel/laravel myProje
Raheel Hasan
  • 5,753
  • 4
  • 39
  • 70
5

Delete Vendor then composer install

Hassan Raza
  • 501
  • 7
  • 8
3

I also had that error. But none of the above solved the issue. So i uninstalled and again installed the composer. Then i did composer update. and the problem was fixed.

Srijan Karki
  • 1,576
  • 2
  • 14
  • 21
3

You are missing vendor folder, probably its new cloned repository or new project

the vendor folder is populated by composer binary which reads composer.json file or system requirements and installs packaged under vendor folder and create an autoload script that has all classed

composer update
AWS PS
  • 4,420
  • 1
  • 9
  • 22
2

Before you carry out the following instructions you need to make sure you have composer installed globally on your machine; Open you Mac terminal and run the following command:

curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

once composer is installed globally run the following command after you are in the directory of the project:

composer install

once completed in it update and install all the required packages.

Krishneil
  • 1,432
  • 1
  • 18
  • 26
2

I had same problem with laravel and artisan, the solution:

php artisan key:generate
Marcelo Agimóvel
  • 1,668
  • 2
  • 20
  • 25
2

We got an error because we have missing vendor folder in our project, The vendor directory contains our Composer dependencies.

Need /vendor folder because all packages are there and including all the classes Laravel uses, A problem can be solved after following just two steps:

composer update --no-scripts 
composer update
  • --no-scripts: Skips execution of scripts defined in composer.json
  • composer update: This will check for newer versions of the libraries you required in your project. If a newer version is found and it's compatible with the version constraint defined in the composer.json file, it will replace the previous version installed. The composer.lock file will be updated to reflect these changes.

These two commands, we will Recreate the vendor folder in our project and after that our project will be working smoothly.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
1

I got this when I did composer update instead of composer install.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
Mick
  • 1,401
  • 4
  • 23
  • 40
1

I added composer.lock file to .gitignore, after commit that file to repository error is gone :)

Alupotha
  • 9,710
  • 4
  • 47
  • 48
1

my problem is solved by

composer update
composer install
php artisan key:generate

if you any other problem you can clear cache and config Clear Route cache:

php artisan route:cache

Clear View cache:

php artisan view:clear

Clear Config cache:

php artisan config:cache
sanjay
  • 695
  • 11
  • 22
1

Something I realise is your composer.json file will have some sort of script like

"scripts": {
    "post-root-package-install": [
        "php -r \"copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "php artisan key:generate"
    ],
    "post-install-cmd": [
        "php artisan clear-compiled",
        "php artisan optimize"
    ],
    "pre-update-cmd": [
        "php artisan clear-compiled"
    ],
    "post-update-cmd": [
        "php artisan optimize"
    ],
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover"
    ]
},

what works for me:

"scripts": {
    "post-root-package-install": [
        "@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
    ],
    "post-create-project-cmd": [
        "@php artisan key:generate"
    ],
    "post-autoload-dump": [
        "Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
        "@php artisan package:discover"
    ]
},

removing post install cmd helped running composer install without any issue.

Hope this helps

Cheers!!

usrNotFound
  • 2,680
  • 3
  • 25
  • 41
1

Delete vendor folder and run composer install command. It is working 100%

orxanzadeh
  • 11
  • 2
0

In my case I had to enable another extension, namely php_mbstring.dll in the php.ini file before it could work. It's listed under extension=php_mbstring.dll. Find it in the php.ini file and remove the semi-colon (;) in front of it and save the file.

After this run install composer again in the root directory of your Laravel applcication and is should work.

Bono
  • 4,757
  • 6
  • 48
  • 77
0

If you are a Windows user you may uninstall Composer. Then install Composer. After that you install Laravel. Maybe it will work.

clemens
  • 16,716
  • 11
  • 50
  • 65
0

this works for me: after installing the project, I open the project's folder and run these two commands

composer update

composer require doctrine/dbal
Wria Mohammed
  • 1,433
  • 18
  • 23
0

I don't know if I am relevant -

I have downloaded the Github release of laravel and installed with lando, and failed to start it.

In lando recipe, I had to add php: 8.1 in .lando.yml

name: ltest1
recipe: laravel
config:
  webroot: public
  php: 8.1

and

$ lando ssh
$ composer install
$ php artisan key:generate
Paul Bradbury
  • 482
  • 6
  • 8