How to Install Composer in Debian


Debian is a free and open-source Linux operating system developed by the Debian Project, which is backed by the public. Typically, one of the most often-used Linux distributions is Debian. Debian regularly releases new distributions, with the next candidate coming after a time-based freeze.

The widely used PHP dependency management tool Composer was created to simplify the installation and updating of project dependencies. The extra packages that a project requires will be recognized, and it will install them for you using the correct versions in line with the project’s specifications. When installing a package for your project, the composer checks to see if any additional dependencies are needed.

You will learn how to update PHP Composer and install it on Debian in this tutorial.

Installing PHP Composer

On Debian OS, it is a good practice to upgrade your system before installing any new applications to ensure everything runs properly.

Run this command to update the system’s cache repository:

$ sudo apt update

Install-Composer-Ubuntu-22-04

Run the command below to update all of the installed packages on the system.:

$ sudo apt upgrade

Install-Composer-Ubuntu-22-04

You need to install some pre-requisites packages that are necessary for PHP composer installation which are explained below:

$ sudo apt install php-cli wget unzip php-zip

After installing the essential core package, you should now download the composer using the wget command as shown below:

$ wget -O composer-setup.php https://ge HYPERLINK "https://getcomposer.org/installer"tcomposer.org/installer

When you finished downloading the application then you can install it by following two different methods on Debian as explained below:

Install-Composer-Ubuntu-22-04

Local Installation of PHP Composer

This installation method requires you to download the composer file by accessing the root directory first and then you can install it using the following command:

$ sudo php composer-setup.php --install-dir=/project_directory

Install-Composer-Ubuntu-22-04

You can access the composer in the project’s directory by typing the following command:

$ sudo php composer.phar

Install-Composer-Ubuntu-22-04

You should be able to use the PHP composer after the execution of this command.

Global Installation of PHP Composer

This will start downloading the composer and give you a directory path where it is downloading it as shown below.

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

Following the process, you may utilize the PHP composer

$ sudo composer

It will prompt you if you want to run a composer as a user and you can continue doing this by writing yes as shown below.

Install-Composer-Ubuntu-22-04

Update PHP Composer

If you are using an older version, then this command will update to its latest version if its available on your Debian Linux system.

$ sudo composer self-update

Install-Composer-Ubuntu-22-04

Conclusion

In this post, we learned how to install PHP Composer on the Debian Linux system using two different methods which are local installation and global installation. Additionally, we covered installing the PHP Composer required packages and updating the version of PHP Composer installed on a Debian OS.

Print Friendly, PDF & Email
Categories