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-curlStep 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 -VThe output terminal below:
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/apiclientAlternatively, 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
f
Comments
Post a Comment