Ripeworks

Using Composer Globally

08 Feb 2013

< More

Update (10/29/2013): You can now install packages globally! It looks like this: composer global require package-name:version

Package managers are great. One of the great things about npm -g or gem is the ability to expose bin scripts to provide utilities for developers.

In Composer, currently there is no support for this.

I wrote a little script that will set up a Composer location to be used globally. It’s super easy to use:

$ curl https://gist.github.com/tamagokun/4242494/raw/3325cac939660ca2e7962185cfb42ee4f361b83e/global_composer.sh | sh
Sweet.
Be sure to add $HOME/.composer/bin to your PATH

Require a package:

$ cd ~/.composer && composer require package-name:version

Here is the script source: