Last Updated: February 25, 2016
·
13.14K
· markushausammann

Using composer to manage global packages

It's possible to use composer to manage global packages the way PEAR functions. Most often you don't want that but it can be helpful for QA packages like phploc, etc.

In the following example we install phing globally in a shell script:

#!/bin/bash

# Install composer and add it to the system path
curl -sS https://getcomposer.org/installer | php 
mv composer.phar /usr/local/bin/composer

# Install Phing globally with Composer
composer global require phing/phing:2.6.1

This will install phing to the $COMPOSER_HOME directory, which is by default:

~/.composer

Therefore, if you want phing and other PHP executables to be globally available, add:

~/.composer/vendor/bin

to your system path. If you want to change the location of the composer home, you can do that by setting the COMPOSER_HOME var before installing the package:

COMPOSER_HOME="/your/path/to/composer/home" 
composer global require phing/phing:2.6.1