Friday, May 9, 2025How to install Composer
Keven Client A. Cataluña @LinkedIn
Introduction

This guide explains how to install Composer by downloading the installer, verifying its hash, and adding it to the system's PATH to make the composer commands available globally.

Steps1. Download the Composer installer script
    php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  
2. Verify the installer script (SHA-384 hash)
    php -r "if (hash_file('sha384', 'composer-setup.php') === 'dac665fdc30fdd8ec78b38b9800061b4150413ff2e3b6f88543c636f7cd84f6db9189d43a81e5503cda447da73c7e5b6') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
  
      Installer verified
  
3. Run the installer script
    php composer-setup.php
  
      All settings correct for using Composer
  Downloading...

  Composer (version 2.7.7) successfully installed to: /home/development/composer.phar
  Use it: php composer.phar
  
4. Remove the installer script
    php -r "unlink('composer-setup.php');"
  
5. Move the Composer to the global path
    sudo mv composer.phar /usr/local/bin/composer
  
6. Verify the Composer installation
    composer -V
  
      Composer version 2.7.7 2024-06-10 22:11:12
  PHP version 8.3.9 (/usr/bin/php8.3)
  Run the "diagnose" command to get more detailed diagnostics output.