How to install php composer on Linux and Windows
John Mwaniki / Updated on 07 Jul 2024Composer 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
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.
3). Set the install mode to the recommended one.
4). Click the Next button
5). Select php.exe file, click the Next button
6). No need to add proxy URL, click the Next button to continue.
7). Click the Install button to continue. The installation loading will take place.
The composer starts downloading.
8). Once the installation has completed loading, click Next
9). The installation processes have been completed, click Finish to close the installation window.
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.
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: