How to install php composer on Linux and Windows
  John Mwaniki /   19 Aug 2021

How to install php composer on Linux and Windows

Composer is a dependency manager for PHP. It is the recommended method for installing most of the PHP libraries.

It helps you manage (download, install and keep up to date) the dependencies (PHP extensions and libraries) you require on a project-by-project basis.

In this tutorial, you will learn how to install composer on your Windows PC and Linux.

Note: Before installing composer, you need to have installed PHP or applications such as XAMPP, WAMP, EasyPHP etc on your PC as Composer needs a PHP executable to work.

Installation of Composer on Windows

Follow these steps:

1). Download the installer file by accessing this download link: https://getcomposer.org/Composer-Setup.exe

Downloading PHP composer

2). After downloading is finished, double-click the Composer-Setup.exe file.
Important: During the installation process, you need to make sure you are connected to the Internet because the installer will download composer and some of its necessary components.

If you get the prompt below, click on the "Run" button.

Running composer setup file on windows

3). Set the install mode to the recommended one.

Selecting PHP composer installation mode on windows

4). Click the Next button

Choosing composer setup installation options

5). Select php.exe file, click the Next button

Choosing the PHP commandline to use in running composer on windows

6). No need to add proxy URL, click the Next button to continue.

Choosing if you need proxy server during composer installation

7). Click the Install button to continue. The installation loading will take place.

Installing php composer on windows PC

The composer starts downloading.

Running the composer installation script

8). Once the installation has completed loading, click Next

Composer installation and usage information

9). The installation processes have been completed, click Finish to close the installation window.

Completing composer setup

Now you are done and can start managing your project dependencies via composer.
To run composer and view its version and other important information, open the command prompt and write command composer.

Using php composer on windows command prompt

Installation on Linux

Update your packages with the following command:

sudo apt-get update

Install the curl utility:

sudo apt-get install curl

Download the installer:

sudo curl -s https://getcomposer.org/installer | php

Move the composer.phar file:

sudo mv composer.phar /usr/local/bin/composer

Use the composer command to test the installation. If Composer is installed correctly, the server will respond with a long list of help information and commands:

Using php composer on Linux terminal