Debian

How to install and use PHP composer on Debian 10

How to install and use PHP composer on Debian 10
Composer is a well-liked dependency manager for PHP, and it helps manage all the required packages for your project, and it can install and update your packages. When the composer installs the package related to your project, it will inspect whether another dependency package is necessary or not. If it is indispensable, then the composer played a vital role there; it starts installing that dependency.

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:

$ sudo apt update

For upgrading the system's installed packages, type the command given below:

$ sudo apt upgrade

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:

$ sudo php composer.phar

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:

$ sudo composer

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.

Conclusion

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.

Middle mouse button not working in Windows 10
The middle mouse button helps you scroll through long webpages and screens with a lot of data. If that stops, well you will end up using the keyboard ...
How to change Left & Right mouse buttons on Windows 10 PC
It's quite a norm that all computer mouse devices are ergonomically designed for right-handed users. But there are mouse devices available which are s...
Emulate Mouse clicks by hovering using Clickless Mouse in Windows 10
Using a mouse or keyboard in the wrong posture of excessive usage can result in a lot of health issues, including strain, carpal tunnel syndrome, and ...