How to Install Composer on Ubuntu 18.04 Bionic Beaver

Install Composer on Ubuntu 18.04

In this article, we will have explained the necessary steps to install and configure Composer on Ubuntu 18.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

Composer is a best dependency manager for PHP. Composer can install, update and pull in all the required PHP packages to your project directory. At the time of installing package, composer will check for dependencies of package and if dependent package are there then it will also install dependencies.

Install Composer on Ubuntu

Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.

Step 2. Install Composer.

Now that we have php cli installed on our machine, we can download the composer installer with:

File composer-setup.php will be downloaded to current working directory. After that, check the data integrity of the script by comparing the script SHA-384 hash on the Composer Signatures page.

Now run the following command to verify that the installation script is not corrupted:

You will get following output if the hashes match:

Next, the following command will install Composer in the /usr/local/bin directory:

It will show you output as below:

At last, you can verify the installation by typing:

The command above, will print the Composer’s version, commands and arguments:

That’s all you need to do to install Composer on Ubuntu 18.04. I hope you find this quick tip helpful. If you have questions or suggestions, feel free to leave a comment below.