Composer is one of the core tooling we use at EasyBib when we work on the various products for the company. The following deck of slides is from a talk I gave at the Berlin PHP Usergroup meetup in November.
In addition, there were a few questions how dependencies are handled in a project when installed through composer’s global command:
- Do you have to require the autoloader from
$COMPOSER_HOME in order to use code which is installed through
./composer global require?
- How does composer handle different versions of dependencies with global vs. local?
Loading global vendors
This is a tricky question! Composer will not require regular vendors automatically for you.
The global command should be used to install and maintain cli-tools (like phpunit) or composer plugins. And not to install libraries globally.
When plugins are installed globally, they get loaded automatically from the
$COMPOSER_HOME. You don’t need to put them into every project’s
Different versions of a dependency
When you install a plugin through global and
require another version locally in a project, the locally installed version wins once it’s installed.