How to install Composer on CentOS 7

Install Composer on CentOS

Composer is one the best dependency management tool for PHP which can install and update project dependency seamlessly. When installing a package it also checks on which another package current package depends on and then it installs all the dependencies. In this tutorial, you are going to learn how to Composer on CentOS 7.

Prerequisites

Before you start to install Composer on CentOS 7. You must have the non-root user account on your server/desktop with sudo privileges.

1. Install Composer

Before you install Composer update system software packages by typing

sudo yum -y update

Now you should install some dependencies for Composer, you can do so by typing

sudo yum install php-cli php-zip wget unzip

Enter following commands to download Composer Setup.

cd ~
curl -sS https://getcomposer.org/installer -o composer-setup.php

Now, you should verify that the installer matches the SHA-384 hash for the data integrity of latest installer found on the Composer Public Keys or Signatures page by running the following command.

After installing package you will see that Composer created three files composer.json file,composer.lock file which contains package names with version, and vendor directory. Enter the following command to check.

Now, you have installed package guzzle, create a file test.php and copy following code inside that file. It will check status code of a URL if it loads successfully it will give 200 otherwise different number.