Huu Phan | Blog Linux operating system | Linux operating system -Blog Huu Phan | www.huuphan.com
huuphan.com. Powered by Blogger.

Install Composer on Ubuntu 21.04

 In this tutorial, How to install and use PHP package manager Composer on Ubuntu 21.04

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 https://getcomposer.org/

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 https://getcomposer.org/installer -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

f

post new :

Huu Phan | Blog Linux operating system | Huu Phan ~ Zimbra Mail Server,linux,bash script,centos,linux command | www.huuphan.com