How to Install Composer on Ubuntu 21.04: A Step-by-Step Guide


In this tutorial, How to install and use PHP package manager Composer on Ubuntu 21.04. In the evolving landscape of web development, managing dependencies efficiently is crucial for project success. Composer, a dependency management tool for PHP, allows developers to manage libraries and packages effortlessly. 

This article provides a comprehensive guide on installing Composer on Ubuntu 21.04. Whether you're setting up a new project or maintaining an existing one, understanding how to install Composer can streamline your development process, ensuring that all necessary packages are up-to-date and compatible.

What is PHP Composer?

Composer is a tool for dependency management in PHP. It allows you to declare the libraries your project depends on and it will manage (install/update) from

Install Composer PHP package manager

The command below install Composer not just limit Ubuntu, you can use Debian and Other similar Linux systems.the latest version of Composer is not available through from APT ( Ubuntu or Debian) and Yum/DNF for Redhat-based operating systems. We will install it Github repository.

Step 1: Install PHP and cURL

sudo apt install -y curl unzip php php-curl
Step 2: Download Composer on Ubuntu
curl -sS -o composer-setup.php

 Step 3: Use the PHP to install Composer

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

 Step 4: Check Composer Version

composer -V
The output terminal below:

Install Composer on Ubuntu 21.04 

 How to install packages with Composer

The syntax use install any packages

composer require package-name

For example, Install google/apiclient package
composer require google/apiclient
Alternatively, we can use the composer.json file to install multiple packages
vi composer.json

"require": {
"google/apiclient": "^2.12",
"monolog/monolog": "1.17.*"

composer update

Update Composer
composer self-update

 Install Composer on Ubuntu 21.04


Successfully installing Composer on Ubuntu 21.04 marks a significant step towards efficient dependency management in your PHP projects. With Composer, you can now easily specify, install, and update libraries needed for your applications, allowing for a more organized and robust development environment. By following the steps outlined in this guide, you should have Composer ready and running, paving the way for a smoother and more productive coding experience. 

Remember, staying updated with Composer’s latest features and best practices can further enhance your development workflows.  Thank you for reading the page!


Popular posts from this blog

zimbra some services are not running [Solve problem]

How to install php7 on centos 6

Bash script list all IP addresses connected to Server