How To Install and Use PHP Composer on Ubuntu 18.04 | aws-ec2

Composer is a dependency manager for PHP (similar to npm for Node.js or pip for Python). Composer will pull in all the required PHP packages your project depends on and manage them for you.

In this tutorial, we’ll show you how to install and use Composer on an Ubuntu 18.04 machine. The same steps can be used for Ubuntu 16.04.

Prerequisites

Installing PHP Composer

To install Composer on your Ubuntu system, perform the following steps:

Before downloading and installing Composer, first update the packages index and install the necessary requirements:

sudo apt update
sudo apt install wget php-cli php-zip unzip
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  1. The command above will download the composer-setup.php file in the current working directory.
  2. Next, we need to verify the data integrity of the script by comparing the script SHA-384 hash with the latest installer hash found on the Composer Public Keys / Signatures page.We will use the following wget command to download the expected signature of the latest Composer installer from the Composer’s Github page and store it in a variable named HASH:
$ HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
$ php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

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

The last step is to verify the installation:

$ composer
______
/ ____/___  ____ ___  ____  ____  ________  _____
/ /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.8.5 2019-04-09 17:46:47

Usage:
    command [options] [arguments]

Renato Lucena

Developer PHP, Laravel. Goiania-GO https://www.linkedin.com/in/renato-de-oliveira-lucena-33777133/

Você pode gostar...