Composer is used for dependency management in PHP and is generally created to facilitate the installation and updating of dependencies. The way Composer works is that it checks project packages and installs them according to the appropriate versions and based on the user’s project configuration. So, this article shows how you can install Composer in Ubuntu 20.04.
Here are the requirements before installing Composer on Ubuntu 20.04:
You can use Composer in all modern PHP frameworks and platforms like Laravel or Drupal. Let’s examine a simple and complete guide to have this great tool on Ubuntu on our Linux VPS or operating system.
Before you start the installation, update your system, so, open the terminal, and run these commands:
sudo apt update
sudo apt upgrade
Tip: An administrative computer runs these commands, so, you have to enter your system password.
Composer depends on some essential packages, including curl and php-cli Install them by executing the following command:
sudo apt install curl php-cli
You can install Composer on Ubuntu with just one command line. To do this and install the required files from the official Composer website, use the curl tool, so that this tool will be installed on your system:
curl -sS https://getcomposer.org/installer -o composer-setup.php
After a successful installation process, you will receive a message indicating that your installation was successful:
Before proceeding, it’s always a good practice to verify the integrity of the installer script. You can achieve this by using SHA-384 verification with the following command:
HASH="$(curl -sS https://composer.github.io/installer.sig)"
Verify the signature by running:
php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
If the installer is verified, you should see the message: installer verified.
To install Composer locally for a specific user, run the following command:
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
To enable Composer globally, allowing it to be accessed from any directory, use the following command:
sudo mv composer.phar /usr/local/bin/composer
You can verify the successful installation of Composer by running the following command:
composer --version
In summary, here you have learned how to install Composer on Ubuntu 20.04 and test it correctly. Read all the steps carefully to have a successful installation and enjoy using this great assistant. If you have any questions or problems, you can share them with us in the comments section. Share this blog with sone who need it.
How useful was this post?
Click on a star to rate it!
Average rating 3 / 5. Vote count: 10
No votes so far! Be the first to rate this post.
Foolproof Backup refers to a backup system or strategy that is designed to be highly reliable and vi...
After successfully installing Ubuntu 22.04, your network interface will by default assign an IP addr...
What is your opinion about this Blog?