Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

i960's avatar
Level 3

Composer install failing, vendor folder missing

This is an odd one for me. Been using Homestead since it came out, composer longer than that, countless Laravel projects. Never once have I had this issue before and it's baffling me. Thought I would throw it out here in case I am missing something obvious.

I have a new install of Homestead and a new Laravel project. Like I always do, I run composer create-project inside the Homestead VM to get started. Not once has this failed me before, until today. The result is that laravel/laravel gets downloaded, but no dependencies are installed. The vendor folder is missing. Composer tries to run the post install commands, but they fail obviously since vendor is missing. I'm ssh'd in as the vagrant user and permissions are correct. I even tried sudo and I get nothing. Composer.json is in the root of the project and looks good. Not sure what's going on, but here's the output:

vagrant@homestead:/var/www$ sudo composer create-project --prefer-dist laravel/laravel myproject.app
Installing laravel/laravel (v5.2.15)
  - Installing laravel/laravel (v5.2.15)
    Downloading: 100%

Created project in myproject.app
> php -r "copy('.env.example', '.env');"
> php artisan clear-compiled
PHP Warning:  require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstrap/autoload.php on line 17

Warning: require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstrap/autoload.php on line 17
PHP Fatal error:  require(): Failed opening required '/var/www/myproject.app/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:') in /var/www/myproject.app/bootstrap/autoload.php on line 17

Fatal error: require(): Failed opening required '/var/www/myproject.app/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:') in /var/www/myproject.app/bootstrap/autoload.php on line 17
Script php artisan clear-compiled handling the pre-update-cmd event returned with an error


  [RuntimeException]
  Error Output: PHP Warning:  require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstra
  p/autoload.php on line 17
  PHP Fatal error:  require(): Failed opening required '/var/www/myproject.app/bootstrap/../vendor/autoload.php' (include_path='.:/usr/share/php:') in /var/www/myproject.app/boots
  trap/autoload.php on line 17

Running composer install or composer update results in the same.

With more verbose, I get this:

vagrant@homestead:/var/www/myproject.app$ composer -vvv install
Reading ./composer.json
Loading config file ./composer.json
Checking CA file /etc/ssl/certs/ca-certificates.crt
Executing command (/var/www/myproject.app): git branch --no-color --no-abbrev -v
Executing command (/var/www/myproject.app): git describe --exact-match --tags
Failed to initialize global composer: Composer could not find the config file: /home/vagrant/.composer/composer.json
To initialize a project, please create a composer.json file as described in the https://getcomposer.org/ "Getting Started" section
> pre-update-cmd: php artisan clear-compiled
Executing command (CWD): php artisan clear-compiled
PHP Warning:  require(/var/www/myproject.app/bootstrap/../vendor/autoload.php): failed to open stream: No such file or directory in /var/www/myproject.app/bootstrap/autoload.php on line 17

Not sure why I'm getting the whole "Failed to initialize global composer" thing. I googled it and came up with nothing relevant. Any ideas?

0 likes
7 replies
i960's avatar
Level 3

Well, I worked around this issue by using the laravel installer instead. Now composer works fine. I can add packages to composer.json and do a composer update and everything works. So weird. I've never used the laravel installer before and composer create-project as always worked in the past. I guess I'll be switching now. :D

mpenna's avatar

@i960 I'm also struggling with this issue. When I try to install any of the previous versions of Laravel I get this same error. Latest version 5.2.29 installs OK. You mentioned that we need to update our composer.json file but I'm not sure what sort of update needs to be done. I've gone through the links you pointed to, but couldn't find any clear indication on how to solve this issue. Further help would be greatly appreciated.

cyrrill's avatar

This will fix it:

        "post-install-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postInstall",
            "php artisan optimize"
        ],
        "post-update-cmd": [
            "Illuminate\\Foundation\\ComposerScripts::postUpdate",
            "php artisan optimize"
        ]
giovannipds's avatar

Try this, in your composer.json (that "@" before the command, as suggested by barryvdh, here:

"pre-update-cmd": [
    "@php artisan clear-compiled"
],

Now:

composer install

Worked for me.

1 like
hashik's avatar

rewrite command

for installing laravel project, we have to specify the version you want

1: if you want latest version of laravel

composer create-project --prefer-dist laravel/laravel myproject.app

2: if you want specific version of laravel composer create-project --prefer-dist laravel/laravel myproject.app "5.2.*"

so u will get full directory with laravel project

regards hashik

try this

3 likes
sumedha's avatar

I got same issue and I fixed it by using composer only. There is only one thing you can do instead of creating project via "laravel new project_name" just use "composer create-project laravel/laravel project_name".

When we create project via laravel command we don't even get env file, only env.example will be there and we need to make env using this env.example file also there would be no Vendor folder.

When we use composer's command we can have vendor folder too and both env files we don't need to make extra env.

Please or to participate in this conversation.