The main goal of Composer, a popular PHP dependency management tool, is to simplify the installation and updating of project dependencies. Based on the project parameters, it will identify which extra packages are needed for a particular project and install them for you using the appropriate versions. Composer is also often used for bootstrapping new projects that are based on popular PHP frameworks such as Symfony and Laravel.
Step 1: Visit the following website to download

Run this command
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"

step 2:
Run this command
php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Then run this command
php composer-setup.php

Then run this command this command
php -r "unlink('composer-setup.php');"
or
sudo php /tmp/composer-setup.php --install-dir=/usr/bin --filename=composer

Final step: move composer file in bin directory
sudo mv composer.phar /usr/local/bin/composer


I’m Abhishek, a DevOps, SRE, DevSecOps, and Cloud expert with a passion for sharing knowledge and real-world experiences. I’ve had the opportunity to work with Cotocus and continue to contribute to multiple platforms where I share insights across different domains:
-
DevOps School – Tech blogs and tutorials
-
Holiday Landmark – Travel stories and guides
-
Stocks Mantra – Stock market strategies and tips
-
My Medic Plus – Health and fitness guidance
-
TrueReviewNow – Honest product reviews
-
Wizbrand – SEO and digital tools for businesses
I’m also exploring the fascinating world of Quantum Computing.
[…] install composer by using this […]