Composer is a popular dependency/package manager used in most PHP projects. If you are PHP developer, installing composer is the next step after you install the web and database servers on your development environment. Installing Composer is not that hard on Windows and the good news is it is even easier on Ubuntu, in my case Ubuntu 20.04.
Install PHP First
You need to install PHP first if it is not already available on your system.
First update the package managers datababse
sudo apt update
Next install PHP using the following command
sudo apt install curl php-cli php-mbstring git unzip
Download and Install Composer
Installing Composer is very simple as it provides an installation wizard made with PHP.
Switch to your home directory and download composer installer.
cd ~ curl -sS https://getcomposer.org/installer -o composer-setup.php
Start installer using the command below
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
The installer will download and install composer automatically. When you see a message like below than you are done!
All settings correct for using Composer
Downloading... Composer (version 2.0.9) successfully installed to: /usr/local/bin/composer
Use it: php /usr/local/bin/composer
You can confirm the installation with the following command
And if everything is ok you will see output like this
Composer version 2.0.9 2021-01-27 16:09:27
Congratulations and happy PHP coding.