Install composer using CLI in ubuntu (Globally)

Steps For Installing PHP Composer on Ubuntu

STEP 1: Update You distribution

Enter this command to update the local repository lists.

sudo apt-get update
Maker sure you get this reading package lists…. Done Message at the end!

STEP 2: Download the Composer Installer

run the below command in your root directory (We are installing composer globally)

php -r "copy('', 'composer-setup.php');"

Step 3: Verify Integrity of the Download

1. Visit the Composer Public Keys page. Copy the Installer Signature (SHA-384).
2. Set the code shell variable:

3. Run the script below to compare the official hash against the one you downloaded:

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

Step 4: Install PHP Composer

1. Installing PHP Composer requires curl, unzip, and a few other utilities. Install them by entering the following:

sudo apt-get install curl php-cli php-mbstring git unzip
The process may take a while to complete for additional Downloads and make sure to permit the installation process

2. To install to /usr/local/bin. enter:

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

The installer should output:

Check the composer version by running command composer –version or composer -v

That’s it hope it helps someone there.