Magento Tutorials

How To Install and Use Composer on Ubuntu 20.04

Hello friends,

Here we are with another tutorial on the installation and use of Composer on Ubuntu 20.04. So, let’s get going! Before getting into the installing part, let us first briefly brush you all up about what exactly is a composer and its main use.

Introduction:

Composer is a prevalent dependency manager in PHP. Composer enables you to specify the PHP libraries that your project is dependent on, and it pulls and manages all the libraries and dependencies by using the appropriate versions according to the requirements of your project. Composer can be used in all the latest PHP frameworks as for example Laravel, Symfony, Drupal, and Magento.

Steps to install Composer on Ubuntu 20.04

Step 1 — Installing PHP and Additional Dependencies

First, update the package manager cache

sudo apt-get update

Next, run the following command to install the required packages:

sudo apt-get install php-cli unzip zip

You will be prompted to confirm installation by typing Y and then ENTER.

Step 2 — Downloading and Installing Composer

cd ~

curl -sS https://getcomposer.org/installer -o composer-setup.php

To install composer globally, use the following command which will download and install Composer as a system-wide command named  composer, under /usr/local/bin:

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

To check your installation, run:

composer

Step 3 — Using Composer in a PHP(Magento 2) Project

When a required package relies on a system library that is currently not installed on your server, you will get an error telling which requirement is missing:

composer require Vendor/Extension

Step 4 — Updating Project Dependencies

Whenever you want to update your project dependencies to more recent versions, run the update command:

composer update

You can also update one or more specific libraries by specifying them like this:

composer update Vendor1/Extension1 Vendor2/Extension2

Closure:

So, here we have demonstrated How To Install and Use a Composer on Ubuntu 20.04. Make sure to perform all the steps carefully for a smooth installation. You can also upgrade your Magento version with zero downtime and data loss by using our Magento Upgrade Service.

We will be glad to receive from you if there are any queries or doubts you have. Share this blog with your friends.

Happy Coding!

Click to rate this post!
[Total: 15 Average: 4.8]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate 🎖️ Certified Magento Developer👨‍💻. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.🏏

Recent Posts

How to Integrate ChatGPT with Laravel Application?

In this guide, we'll explore how to integrate ChatGPT, an AI-powered chatbot, with a Laravel…

2 days ago

What are Net Sales? How to Calculate Your Net Sales?

In the world of business, understanding financial metrics is crucial for making informed decisions and…

4 days ago

Magento 2 Extensions Digest April 2024 (New Release & Updates)

Welcome to the MageComp Monthly Digest, where we bring you the latest updates, releases, and…

4 days ago

The ABCs of Geofencing: Definition, Features and Uses

In this era, businesses are always on the lookout for ways to engage with their…

5 days ago

How to Delete Product Variant in a Shopify Remix App using GraphQL Mutations?

Managing a Shopify store efficiently involves keeping your product catalog organized. This includes removing outdated…

6 days ago

6 Innovative Tools Revolutionizing E-Commerce Operations

E-commerce has transformed the way consumers shop for products and services and interact with businesses.…

1 week ago