How to Install and Use PHP Composer on Debian 12

PHP Composer helps PHP developers to manage the packages, libraries, and dependencies of PHP.  PHP developers can easily install, remove, and update the PHP packages and develop feature-rich PHP applications. 

The PHP Composer can be installed on Debian 12 with the method explained in this post. Also, the basic usage of the PHP Composer on Debian 12 has also been explained.


For the installation of the PHP Composer on Debian 12, ensure the following:

  • PHP package has been installed
  • Apache has been installed, if not then follow the blog, to install and configure Apache Web Server
  • A stable internet connection

How to Install the PHP Composer on Debian 12?

Follow the below-mentioned instructions for the installation of the PHP Composer. 

Step 1: Update the Packages

For ensuring the latest package of PHP Composer has been installed, update the packages:

$ sudo apt update

Step 2: Download the PHP-Composer Installer

Now, download the PHP Composer installer script file with the PHP:

$ php -r "copy('', 'composer-setup.php');"

Step 3: Install the PHP Composer

After downloading the PHP Composer’s PHP script file, either install it globally or by moving it to a specific directory. It is recommended to create a new directory and install it and then install the PHP Composer:

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

Step 4: Make the Installed PHP Composer Executable

After installing the PHP Composer, make it executable by changing its access permissions:

$ chmod +x bin/composer

Step 5: Verify the Installation

To the verification of the installation of the PHP Composer, display its installed version:

$ composer --version

The PHP Composer has successfully been installed on Debian 12. 

What is the Method to Use the PHP Composer on Debian 12?

The PHP composer on Debian 12 can be used to manage the PHP packages. Some basic commands to manage the PHP packages are explained below. 

Initialize the Project

To initialize the project, run the command:

$ composer init

Update PHP Composer

To update the PHP Compose itself, use the command:

$ composer self-update

Install the Dependencies 

To install the dependencies of the composer.son file, run the command:

$ composer install

Install PHP Package

To install the PHP packages, for example, for installing psr/log module in the application, execute the command:

$ composer require psr/log

Remove PHP Package

Use the “remove” option to uninstall the PHP package with the composer:

$ composer remove psr/log

Check Outdated Packages

To display the outdated packages of the project, run the command:

$ composer outdated

This is the easiest way to install and use the PHP Composer on Debian 12. 


Download the PHP script of the “PHP Composer’s Installer” and then execute the command “php composer-setup.php –install-dir=bin –filename=composer” for installing PHP Composer on Debian 12.  In this blog, the installation method of PHP Composer on Debian 12 with its basic usage commands has been explained.