In case you have not heard, but php has just gotten even better with a new dependency management tool. It’s not a package manager like pecl but a dependency management tool. I think the abstract text from the composer site says it better.
Composer is not a package manager. Yes, it deals with “packages” or libraries, but it manages them on a per-project basis, installing them in a directory (e.g. vendor) inside your project. By default it will never install anything globally. Thus, it is a dependency manager.
Anyways, now that we have an idea about what composer is lets move on.I am planning on doing a series of posts which will highlight the benefits of using composer on your project.
I have only used the basic functionality which composer offers in symfony 2 but I am hoping together we can discover some of it’s hidden features.
Just a side note, this posts assumes that you are running ubuntu 12.04 as your operating system.
So lets gets started, open your ubuntu terminal and type the following commands.
curl -sS https://getcomposer.org/installer | php
This above command will download a file called composer.phar , It’s a PHAR (PHP archive), Please make sure you have permission to execute the command.
Once we have composer.phar we can start using it to download our libraries which our project dependents on. We can execute the following command to execute composer.
/usr/bin/php composer.phar --version
If you see a menu with options then congratulations it works.
However, we can make the installation better by installing it globally on the system and also adding it to our system path.
Please execute the following command to install it globally:
mv composer.phar /usr/local/bin/composer
Notice: If you get permission issues please use sudo
Once you get it right, you should be able to execute the following command and get the composer menu.
If you get an output like the one shown below, then you have successfully installed composer.
“Composer version fc3fbdeab3355c2c9d03e496c41b1a3bb9565a49 2013-11-20 14:17:10″
We will end this post here today, The next post will deal with configuring your project dependencies and other basic features offered by composer.