For PHP development, you always require to install any package in your project. When you are working on any PHP framework, you always required to have a composer installed in your system. The Composer is a dependency manager that helps to get install the package in the PHP project. If you are new to PHP development then you will require to have the composer. The composer is not a package, it is just a tool for package management in PHP. This allows us to define and declare the libraries on which that project depends on. It will help out to install automatically those packages. If you are a windows user then the installation is quite similar to other installations. But, if you are a Linux user then it is different. So, today, I will show you how you can install composer in Ubuntu 20.04 LTS.
To start to install composer in Ubuntu, you will have the following requirements. So, I am assuming, you are ready with the below configurations.
- Ubuntu 20.04.2 LTS (As an Operating System)
- An Ubuntu user with Sudo Privileges
- A terminal and command-line access
- PHP (5 or greater)
Initial Updates in Ubuntu to Install Composer
In Linux, before proceeding with any installation process, you will have to check the existing package update. So, here we will check the updates using the apt (Advanced Package Tool). Hence, open the terminal, and let’s check it by hitting the below command.
sudo apt update
After hitting the above command, it will check the updates of all the existing packages.
If the package updates are available then you will have the output something like this.
Here, you can upgrade these updates using the below command.
sudo apt upgrade
The above command will upgrade the available updates. So, after finishing these upgrades, we can proceed to install composer in Ubuntu.
Also, you will have to check the PHP is installed or not. So, to check the PHP version in Ubuntu, simply hit the below command in the terminal.
So, we are good to go to install composer in Ubuntu 20.04 LTS.
How to Install LAMP Stack in Ubuntu 20.04 LTS
Install Composer in Ubuntu
The composer must be installed globally in every system. So, that it will have the global scope for every projects which will gonna create. Otherwise, it will have the limited scope as the project directory level. To install the composer globally, you have to follow these steps here.
Firstly, Open the terminal and go to the home of the directory using the below command.
Add the package repository of composer using the below command.
curl -sS https://getcomposer.org/installer -o composer-setup.php
The above command will add the composer package repository.
After adding the composer package repository, you have to install it using the below command.
sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
Here, the above command will start downloading the composer from the above package repository. Also, it will install it. You can see the response as showing below.
Check Composer in Ubuntu
After the successful installation of composer, it is must to check the version. So, just hit the below command in the terminal.
In the response, you will get the composer version.
If you want to get more detail about the installed composer then simply hit the write the composer and hit enter.
After hitting the above command in the terminal, you will get the below response.
Here, you will have the composer version, options, commands, etc. It shows that composer is installed successfully.
We installed composer in Ubuntu for the PHP development. It is simple and convenient steps to install composer in Ubuntu 20.04. Though, the usage of composer in PHP is bit complex. But, don’t worry, you can search for the available package inside the composer. It will get installed inside the project directory. After installing the package, it will generate a file named composer.json. You will be able to check the details of the installed package there. So, I hope, you will find helpful to this post. Also, don’t forget to write in the comment section for any kind of issue or query related to this post. I will help you as soon as possible.
Leave a Reply