×


Install Composer on Linux Mint 20 - Step by Step Process ?

Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies.

Also, it acts as a package manager for PHP.

It is used to gracefully manage all the packages and dependencies for this programming language hence offloading the developers from the responsibility of doing this manually.

Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related Composer queries on Linux System.

In this context, we shall look into how we can install Composer on a Linux Mint system.


How to install Composer on Linux Mint ?

Before proceeding with this installation procedure, you need to have "PHP" installed on your Linux system with "sudo" privileges.

Then follow the steps given below.


1. Download Composer from its Official Website

First, you need to download Composer from its official website by executing the following command:

$ wget https://getcomposer.org/composer.phar

You can also mention the exact version of Composer in this command that you want to download. 

However, running this command as it is will ensure that you download the latest available version of Composer on your system.


2. Make the Downloaded Composer File Executable

Now, you need to make the downloaded file executable with the command shown below:

$ chmod +x ./composer.phar

This command will not render any messages on your terminal if it is executed without any errors.


3. Change the Path of the Executable Composer File to make it easily accessible

After performing the above-mentioned step, you need to move your executable Composer file to the /usr/bin/composer directory for making it easily accessible. 

You can do this by executing the following command:

$ sudo mv ./composer.phar /usr/bin/composer

You should run the above-mentioned command as it is because omitting the "sudo" keyword from this command will not let you change the path of the executable Composer file. 

Also, if this command will execute without any errors, then it will not produce any messages on your terminal.


4. Verify the Installation of Composer on your Linux System

Finally, you can verify the successful installation of Composer on your Linux system by checking its location with the command shown below:

$ which composer

The location of Composer on our Linux system will be displayed in the terminal which indicates that Composer has been successfully installed on our Linux system.


How to Uninstall Composer from Linux Mint ?

You can easily uninstall Composer from your Linux machine by first executing the command shown below:

$ sudo apt-get purge composer

After executing this command, you can run the following command in your terminal to free up more space on your Linux system:

$ sudo apt-get autoremove


[Need assistance in fixing Software Packages Installation tasks on any Linux Distribution? We can help you. ]


Conclusion

This article covers how to install Composer on your Linux system and use it for handling the packages and dependencies of the PHP programming language. Composer is a dependency manager for PHP (similar to npm for Node.js or pip for Python ).

With Composer, you can specify the PHP libraries your project depends on, and it will pull and manage all libraries and dependencies for you. 

Composer is used in all modern PHP frameworks and platforms such as Laravel, Symfony, Drupal, and Magento.


To install PHP Composer on Ubuntu:

1. Ensure that you have all the necessary requirements installed on your system:

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

2. Composer offers an installer written in PHP that we’ll use to install Composer. Use wget to download the installer:

$ wget -O composer-setup.php https://getcomposer.org/installer

The command above will save the file as composer-setup.php in the current working directory .

3. Run the following command to install Composer in the /usr/local/bin directory:

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

4. To install composer locally enter:

$ sudo php composer-setup.php --install-dir=/path/to/project

5. When a new Composer version is available, you can update your installation using the following command:

$ sudo composer self-update