How to install Composer

Posted on: April 14th, 2023
By: Tadeo Martinez

Please follow the steps below to install Composer for your operating system.

For Windows:

  1. Download the Composer Windows installer from the official website: https://getcomposer.org/Composer-Setup.exe
  2. Run the downloaded installer.
  3. Follow the prompts to complete the installation. The installer will automatically set up the necessary environment variables and make Composer available globally.

For macOS and Linux:

  1. Open your terminal or command prompt.
  2. Run the following command to download the Composer installer:
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  1. Verify the installer’s integrity by running the following command:
php -r "if (hash_file('sha384', 'composer-setup.php') === file_get_contents('https://composer.github.io/installer.sig')) { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"

Please note that the hash in the original command you provided might be outdated. The updated command above fetches the latest hash from the Composer website to ensure the installer is verified correctly.

  1. If the installer is verified, run the following command to install Composer:

php composer-setup.php –install-dir=/usr/local/bin –filename=composer

This command installs Composer in the /usr/local/bin directory and makes it available globally as composer.

  1. Remove the installer file by running:
php -r "unlink('composer-setup.php');"

Check if Composer is installed correctly by running:

composer --version

Have any questions or comments? Write them below!


Leave a Reply

Your email address will not be published. Required fields are marked *