All the latest and modern PHP frameworks and platforms used this tool for their conveniences, such as Laravel, Symfony, Magento, and Drupal.
In this tutorial, you will see how to install PHP Composer on Debian 10 and how it’s helpful for your project. Let’s start.
Installation of PHP Composer on Debian 10
Before getting started with the installation of PHP composer on Debian 10, it is better to start with the updation and up-gradation of the system’s packages.
For updating the system’s cache repository, type the command given below:
For upgrading the system’s installed packages, type the command given below:
After updating and upgrading the system’s packages, type the command given below to install some essential packages required for the installation of PHP composer:
$ sudo apt install php-cli wget unzip php-zip
To continue the installation process, you have to type “y” and hit “Enter.”
The installation of required essential packages on your Debian 10 system is successfully completed.
Now, download the installer written in PHP provided by the Composer using the wget command-line utility; the command for downloading the installer would go like this:
$ wget -O composer-setup.php https://getcomposer.org/installer
Once the installer is downloaded, it’s time to install the composer.
There can be two possibilities to install Composer on Debian 10. Either you can install it locally (in the project directory only), or you can install it globally on your system if you want.
Install PHP Composer locally
If you want to install in a project directory, first, you need to download the composer file in the root directory using the command given below:
$ sudo php composer-setup.php –install-dir=/project_directory
Afterward, simply move to the project’s directory using the cd command and then type the command given below to use the PHP composer in the project’s directory:
After running the above-given command, you can use the PHP composer in your project perfectly fine.
Install PHP Composer globally
If you want to install PHP composer globally on your system, then all you need to do is to download the composer file in the /usr/local/bin directory using the command given below:
$ sudo php composer-setup.php –install-dir=/usr/local/bin –filename=composer
After running the above-given command, you can use the PHP composer by just executing the command given below:
It will prompt a warning not to run composer as root but if you want to run as a root user, then type “yes” and hit “Enter,” and the PHP composer will start working perfectly fine.
This is how you can easily install PHP composer on your Debian 10 Linux system.
Update the PHP Composer on Debian 10
If a new version of PHP composer is introduced and you want to update your older version of PHP composer on your Debian 10 Linux system, you can do so by typing the command given below:
$ sudo composer self-update
This command will update the PHP composer to its latest version.
This post has learned to install the essential packages required for PHP composer and how to install PHP composer locally or globally on the Debian 10 system. This post also contains how to update the installed PHP composer on Debian 10 Linux system.