First of all, I'm a complete newbie to Composer. I've been trying it out since it's a sounds awesome and mainly because Zend Framework 2 uses it.
Zend Framework 2 is actually also the reason for this thread.
It get the basics of Composer. But with my current server setup I have a request, which I can't seem to figure out if possible.
Let me explain.
I have multiple Zend Framework 2 projects:
- /home/morten/sites/Project-1/
- /home/morten/sites/Project-2/
- /home/morten/sites/Project-3/
All of these projects should be running ZF2. When running composer in each project - each of them get their own separate download of the ZF2 Library files. Which is a bit redundant with my setup.
I have a complete and up-to-date download of ZF2 Library located at: /var/www/shared/Zend/
And my php.ini has that path added to PHP's include_path, so the whole ZF2 library is available for all the three projects.
IS IT POSSIBLE to make Composer use in it's setup. Because if I try to change stuff and try things out in the composer files, then it just re-downloads Zend because it's a required component for other modules.
Can this be done? And if yes, how can I do it?
Hope I have explained myself good enough for you guys to understand what I'm trying to do and want :)
Thanks a lot in advance!
Regards, Morten
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:
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.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'svendor
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.