Installing Composer.phar

Posted by Stefan Kecskes on Thursday, June 25, 2015

What is composer?

Now we don’t have to reinvent wheel, we can select the tyre, the rim, the gauge. Same way in PHP we don’t have to write everything from scratch but we use Composer will give us these components so that they will work together without compatibility issues.

Composer is the dependency manager for PHP. That means that chunks of php code, which are tested and each package solves one some problem are packed into a packages and added to packagist repository. Using composer we can get those packages and add them into our codebase, and so reuse the stable code.

How to install Composer?

I will describe here my preferred global installation and by the way the official documentation for Composer is also great. First we download the latest version of composer.phar file using curl

    curl -sS https://getcomposer.org/installer | php

and you should see something like this

    #!/usr/bin/env php
    All settings correct for using Composer
    Downloading...
    
    Composer successfully installed to: /var/www/skey.uk.dev/composer.phar
    Use it: php composer.phar

Now we will move composer.phar to binary folder, so that it is available globally in system, and we rename it to composer

    sudo mv composer.phar /usr/local/bin/composer

Therefore we will be able to use it anywhere without php just by calling

    composer

which will do the same, as if we would run php composer.phar