You might be able to have one composer.json
file stored in /var/www/shared/Zend
, where you would put your dependencies and use Composer do manage them. Then all projects could include the same autoloader.
However, I wouldn't recommend that approach:
- Your project's dependencies (
composer.json
) should be stored with your project. If you want to install your project somewhere else (for instance if you want to move one project to another server), you are missing thecomposer.json
to install the required dependencies. - It will not be possible to update the dependencies of one project, without updating the dependencies of all other projects. If you want to introduce a new feature in Project 1, which requires a new version of a certain dependency, all other projects will get this new version as well - which might introduce backward compatibility breaks if an older feature that Project 2 relies on, is no longer supported. Since you can only have one version of each dependency, it is not possible for two projects to have different versions of the same dependency.
This approach might be useful if all projects will have the exact same functionality and code, but in that case you should probably merge them into one project.
In all other cases, I would suggest to use Composer the way it's supposed to be used: give all projects their own composer.json
file and let Composer download the dependencies per project, in each project's vendor
directory. The downside is that it'll cost you a little more disk space, but you'll get a lot of flexibility for it in return.