如何为5个不同的laravel 5.1项目使用一个供应商目录

I have 5 different Laravel 5.1 projects. How can I use one vendor directory for all projects. Any suggetions?

Insert in composer.json:

"config": {
        "vendor-dir": "plugins"
    }

and change in bootstrap/autoload.php

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

to directory where You setup vendor dir.

This is what worked for me :

I use a vendor directory for each project that contains only autoload.php file. At this file, I added a line, storing the location of the application's directory, eg $GLOBALS['mydir'] = 'absolute path to project'; and I modified the require_once statement, changing the path, pointing to the common vendor directory.

At the common vendor directory, I modified the vendor/composer/autoload_classmap.php and added the line $appDir =$GLOBALS['mydir']; before the return array.

I replaced all $baseDir with the $appDir where /app/ exists at paths (for me there were 23 replacements).

Please note that in my case I have not updated my 5.1 Laravel. After update I think that the same must be done to autoload_static.php. One good reason to use only one vendor directory, is that some host plans have a limit for the files per hosting account and vendor has more than 6000 files.