Composer – installation and explanation


Composer is an irreplaceable tool for managing PHP packages and libraries. I encourage You to read it closer in the article below.

Composer is an application level package installer for PHP. It introduces a standard for managing software and PHP libraries required by your applications. It was created by Nils Adermann and Jordi Boggiano. Supported all the time from March 1, 2012. Composer’s workflow is not new, it is strongly inspired by Node NPM and Ruby Bundler. Dependancy was initially created as PHP port openSUSE libzypp satsolver.

Composer uses the command line to install the selected package – therefore it can be confused with Yum or Apt, but there is a fundamental difference between them – both mentioned install the package or library globally – according to their nature, while Composer installs packages only as part of the project. All packages available on Packagist are available, which is treated as the main repository. An additional feature of Composer is autoload in order to easily use the code of other applications.

Frameworks using composer

The list is long, and includes primarily two currently leading frameworks (Symfony and Laravel), Drupal that supports approximately 8% of all Internet pages, and Magento – one of the largest E-Commerce systems:

  • Symfony 2+
  • Laravel 4+
  • CodeIgniter 3+
  • CakePHP 3+
  • FuelPHP 2+
  • Drupal 8+
  • SilverStripe 3+
  • Magento 2+
  • Yii 1.1+
  • Zend Framework
  • Silex

Windows installation

Installing Composer in a Window’s system is trivial thanks to a dedicated installer especially for this system. We simply go to, download the installer and it’s ready.

ATTENTION! Remember to turn off the open console after installation.

MacOS / Linux installation

We have two options to choose from: Using the Composer .phar file directly as part of the project or global installation. Both options will be described below.

The first option is to manually download the composer.phar file from the site to the project’s main directory or to use the following set of commands (also in the project’s root):

php -r "copy('', 'composer-setup.php');" 
php -r "if (hash_file('sha384', 'composer-setup.php') === 'a5c698ffe4b8e849a443b120cd5ba38043260d5c4023dbf93e1558871f1f07f58274fc6f4c93bcfd858c6bd0775cd8d1') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;" 
php composer-setup.php 
php -r "unlink('composer-setup.php');"

To install Composer globally after using the command set used above in any directory, we use one more command and restart Bash:

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

Remeber to restart terminal after that.

Please leave me comment if you have any question. If you liked this post, go to my instagram and follow me to stay up to date!

You may like