Debian, sometimes known as Debian GNU/Linux, is a free and open-source Linux system developed by the Debian Project, which is supported by the community. Ian Murdock essentially started this project on August 16, 1993. Debian is normally considered as one of the most extensively used Linux distributions. Debian releases new distributions on a regular basis, with the next candidate following a time-based freeze.
Composer is a popular PHP dependency management solution that was designed to make project dependency installation and updates easier. It will determine which other packages a project requires and install them for you, using the right versions based on the project’s needs. When the composer installs a package for your project, it checks to see whether any other dependencies are required. If it’s required, the composer has a key job to play; it begins the installation process. Laravel, Symfony, Magento, and Drupal are just a few examples of current PHP frameworks and platforms that employ this tool for their convenience.
You’ll learn the steps to install PHP Composer on Debian and how to update this composer through this article.
PHP Composer Installation
Before installing PHP Composer in Debian, it’s a good idea to update and upgrade the system’s packages first.
In order to refresh the system’s cache repository, run the following command:
$ sudo apt update |
Type the following command in order to upgrade the system’s installed packages:
$ sudo apt upgrade |
After you’ve updated and upgraded your system’s packages, run the command below to install certain important packages for PHP composer installation:
$ sudo apt install php-cli wget unzip php-zip |
Type “y” and press “Enter” to begin the installation process.
Your Debian system now has all of the required fundamental packages installed. Now, using the wget command-line utility, download the composer’s PHP-based installer:
$ wget -O composer-setup.php https://getcomposer.org/installer |
It’s time to install the composer after you’ve downloaded the installer. There are two ways to install Composer on Debian. You can choose between these two methods to install it on your PC.
- Installing a Composer Using a Local Method
- Installing a Composer Using a Global Method
Install PHP Composer Locally
If you wish to install in a project directory, you must first download the composer file from the root directory using the following command:
$ sudo php composer-setup.php --install-dir=/project_directory |
After running this command, simply use the change directory command to get to the project’s directory, and then type the following command to use the PHP composer in that project’s directory:
$ sudo php composer.phar |
You can utilize PHP composer in your project after running the command above.
Install PHP Composer Globally
To download the composer file to your bin directory on your PC, run the following command:
$ sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer |
You can use the PHP composer by simply performing the command below after running the above-mentioned procedure:
$ sudo composer |
It will advise you not to run composer as root, but if you do, type “yes” and hit “Enter,” and the PHP composer will begin to work normally.
In this article, we have finally discussed how to install PHP Composer on your Debian Linux system.
Update PHP Composer
If its new version is available and you want to upgrade your older version on your Debian Linux system, use the command to update your PHP Composer:
$ sudo composer self-update |
The PHP composer will be updated to the most recent version with this command.
Conclusion
In this tutorial, we learned how to install the PHP Composer essential packages and how to install PHP Composer locally or globally on a Debian Linux system. This article also explains how to update the PHP composer that is installed on a Debian Linux system.