• Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us
TecAdmin
Menu
  • Home
  • Ubuntu 18.04
    • Whats New?
    • Upgrade Ubuntu
    • Install Java
    • Install Node.js
    • Install Docker
    • Install Git
    • Install LAMP Stack
  • Tutorials
    • AWS
    • Shell Scripting
    • Docker
    • Git
    • MongoDB
  • Funny Tools
  • FeedBack
  • Submit Article
  • About Us

How to Install PHP Composer on Ubuntu 20.04

Written by Rahul, Updated on September 21, 2020

The PHP Composer is a package management tool for installing and managing modules for a PHP application. After that you can easily use these modules to your project. It help user to install the required version of php modules under your application. It also maintains all the installed modules details with the version details. All the entries are keeps in a file name composer.json.

This tutorial will help you to install and Use PHP composer on Ubuntu 20.04 LTS systems.

Prerequisites

  • Shell access to a running Ubuntu system
  • PHP must be installed and configured, version 5.3 or higher.

1. Installing PHP

Composer requried PHP to be installed on your system. If you don’t have PHP installed execute below commands to update apt cache and then install php on your system.

sudo apt update
sudo apt install php php-gd php-xml php-cli php-zip

You also need to install some additional packages on your system. Execute below commands on shell.

sudo apt install unzip curl 

Once you installed all the required packages, verify the active php command line version by executing:

php -v

check php cli version

2. Install PHP Composer

Your are ready for installing PHP Composer on Ubuntu 20.04. Now, download the composer executable file on your system using the following command.

curl -sS https://getcomposer.org/installer | php 

Now use the following commands to make composer available globally for all users in your system, which can be used for all PHP applications on that system.

sudo mv composer.phar /usr/local/bin/composer 
chmod +x /usr/local/bin/composer 

After installation of the composer on your system. Type composer at the command prompt. This will provide you composer version details along with options available with composer command.

composer -v 

Install php composer on Ubuntu 20.04

3. Using Composer

You can download the latest version of the composer by executing the same commands used for installation. The composer also has capabilities to update itself. Use the following command to update the composer itself.

For Existing Project:

Switch to the application root directory and run below command. It will read composer.json and install dependencies for the application.

composer install 

Creating New Project:

To create a new project, switch to the project directory and install required modules as below command.

mkdir myapp && cd myapp 
composer require psr/log  

The above command will install psr/log module under the vendor directory. It also create an entry in composer.json and update composer.lock as well.

4. Upgrading Composer

Composer is capable to upgrade itself, So you can run a self-update to upgrade composer to latest version. Otherwise, You can download the latest version of the composer by executing the same commands used for installation.

sudo composer self-update 

Conclusion

In this tutorial, you have learned to install php composer on a Ubuntu system. Also get a basic overview of composer uses over command line.

Share it!
Share on Facebook
Share on Twitter
Share on LinkedIn
Share on Reddit
Share on Tumblr
Share on Whatsapp
Rahul
Rahul
Connect on Facebook Connect on Twitter

I, Rahul Kumar am the founder and chief editor of TecAdmin.net. I am a Red Hat Certified Engineer (RHCE) and working as an IT professional since 2009..

Leave a Reply Cancel reply

Popular Posts

  • How to Install Python 3.9 on CentOS/RHEL 7 & Fedora 32/31 0
  • How To Install VNC Server on Ubuntu 20.04 1
  • How To Install NVM on macOS with Homebrew 0
  • (Solved) apt-add-repository command not found – Ubuntu & Debian 0
  • How to Install .NET Core on Debian 10 0
© 2013-2020 Tecadmin.net. All Rights Reserved | Terms  | Privacy Policy