Composer Dependency Manager Installation

Composer Dependency Manager Installation

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.

All you need to run Composer is PHP 5.3.2+

This tutorial will only show you how to install Composer, if you are interested in more information about Composer, you can visit official Composer website.

Download Composer

Run this command in terminal to get the latest Composer version:

This installer script will simply check some php.ini settings, warn you if they are set incorrectly, and then download the latest composer.phar in the current directory. The 4 lines above will, in order:

  • Download the installer to the current directory
  • Verify the installer SHA-384 which you can also cross-check here
  • Run the installer
  • Remove the installer

Note that this will install latest version to the moment of writing this tutorial, so you can download Composer manually or follow instructions on the official website

Composer Installation

There are two ways to install Composer. Locally as part of your project, or globally as a system wide executable.

Local installation

You can install Composer in your current project directory.

This can be achieved by running four lines of code mentioned above.

It will download composer.phar to your working directory which is a PHP archive.

You can now run Composer using

You can, also, install Composer to a specific directory using –install-dir option, and you can rename it using –filename option by editing 3rd line of code from Download Composer section of this tutorial

Now you can run Composer with the following command:

Global instalation

You can place the Composer PHAR anywhere you want. If you put it in a directory that is part of your system PATH, you can access it globally.

Move composer.phar to a directory that is in your path:

Now you can use Composer by running composer command in Terminal


You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *