Composer is a dependency manager for PHP, it like npm for Node.js or pip to Python. So, it allows you to declare the libraries your project depends on and it will manage (installing/updating) them for you. It is used in all modern PHP frameworks and platforms such as Laravel, Symfony, Drupal, and Magento 2.
This article explains how to install PHP Composer on Ubuntu 20.04 LTS. By downloading the latest release of PHP Composer from their official website.
Installing dependencies packages
However, before starting you have to install some dependencies of Composer like PHP.
01- So, open a terminal and run the following command:
$ sudo apt update $ sudo apt install php libapache2-mod-php php-mbstring php-xmlrpc php-soap php-gd php-xml php-cli php-zip curl
02- Check the version of PHP by executing the below command:
$ php -v PHP 7.4.3 (cli) (built: Mar 26 2020 20:24:23) ( NTS ) Copyright (c) The PHP Group Zend Engine v3.4.0, Copyright (c) Zend Technologies with Zend OPcache v7.4.3, Copyright (c), by Zend Technologies
Installing PHP Composer
01- let’s use the
curl command to download the latest PHP Composer version
$ curl -sS https://getcomposer.org/installer | php All settings correct for using Composer Downloading... Composer (version 1.10.6) successfully installed to: //composer.phar Use it: php composer.phar
02- To make PHP Composer globally available, move it to the binary folder
/usr/local/bin as below:
$ sudo mv composer.phar /usr/local/bin/composer $ sudo chmod +x /usr/local/bin/composer $ source ~/.bashrc
03- Finally, to check if you installed accurately PHP Composer, use the below command check the version:
$ composer -v Composer version 1.10.6 2020-05-06 11:44:22
You have successfully learned how to install PHP Composer on Ubuntu 20.04 LTS. You can now visit the official PHP Composer Documentation page and learn how to get started by creating PHP Projects.
You might want to check the following guides: