Composer test output on Ubuntu 18

How to install Composer on Ubuntu 16.04 and Ubuntu 18.04

Some of our G3 & G4 stacks already have composer preinstalled. In a situation that composer is not installed on your stack, please contact support or follow the guidelines set here for proper installation.

What is Composer? As Composer’s Official site states: “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.”

Why we use it? Magento CMS uses it for updates and installs for Magento components, themes, and modules.

Composer Installation on aMiSTACX

~$ cd /home/ubuntu

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

Verify that the installer matches the SHA-384 hash for the latest installer found on the Composer Public Keys / Signatures page. Copy this hash from that page, and declare it as a shell variable:

e.g. HASH=93b54496392c062774670ac18b134c3b3a95e5a5e5c8f1a9f115f203b75bf9a129d5daa8ba6a13e2cc8a1da0806388a8

Composer Hash Value

Now execute the following PHP script to verify that the composer installation script is safe to run:

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

Success shows the following output:
Installer verified

Note: If you see Installer corrupt, then you’ll need to re-download the installation script again and double check that you’re using the correct hash.

Next, to install composer globally, use the following command which will download and install Composer as a system-wide command named composer, under /usr/local/bin:

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

You’ll see the following output:

Output
All settings correct for using Composer
Downloading…

Composer (version 1.7.3) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer

To test Composer:

~$ composer

Composer test output on Ubuntu 18

To see composer in action please review our “Upgrade Magento 2 using Composer“.

Good to go!

Lead Robot

1 Comment

Comments are closed.