Introduction

Composer is an application for tracking the dependencies of a project. It pulls in all the required PHP packages. It allows to specify a set of libraries for a specific project. With the libraries established, it identifies the versions and dependencies and installs them to the corresponding project.

Prerequisites

  1. SSH access with sudo privileges
  2. Required PHP (>=5.3.2) version should be installed

Implementation

Step 1: Update the Local Repository

$sudo yum -y update

Step 2: Install PHP Dependencies

$ yum install php-cli php-zip wget unzip

Step 3: Download Composer Installer Script

$ php -r “copy(‘https://getcomposer.org/installer’, ‘composer-setup.php’);”

Step 4: Download the authorized signature from Composer’s Github page in the HASH variable

$HASH=”$(wget -q -O – https://composer.github.io/installer.sig)”

Step 5: Compare the official hash against the one which we  downloaded

$ php -r “if (hash_file(‘SHA384’, ‘composer-setup.php’) === ‘$HASH’) { echo ‘Installer verified’; } else { echo ‘Installer corrupt’; unlink(‘composer-setup.php’); } echo PHP_EOL;”

========
Output:
Installer verified
==========

Step 6: Install Composer

$ php composer-setup.php –install-dir=/usr/local/bin –filename=composer

Step 7: Check the installation 

$composer

Step 8: To modify the composer version

$ composer self-update <required version>

Leave a Reply