How To Install Composer On Ubuntu

Last Updated: Feb. 17th 2022 at 4:54pm Tags: blog codeigniter laravel php slim symfony ubuntu yii

Composer is a package manager for PHP.
Most PHP frameworks and projects utilize its feature for updates. Learn more at Composer’s official website.

Requirements

You need curl to download composer and you need php to run composer.

sudo apt update && sudo apt upgrade -y
sudo apt install php7.4-cli curl

Extras

wget and apt-utils have nothing to do with composer, but I commonly use them in these tutorials, now would be a good time to install them. Feel free to skip this step.

sudo apt-get install -y wget apt-utils git php-intl

Install composer

Installing composer is really easy, you just need to run the following one liner:

sudo curl -sS https://getcomposer.org/installer | sudo php -- --install-dir=/usr/local/bin --filename=composer

Download’s the installer from the official website and installs it to the global bin directory as just ‘composer’. It requires root permissions for install.

Using Composer

To list available commands for composer use list:

composer list

To install the defined dependencies for your project, run the install command.

composer install

Find Packages

You can see packages available for download by going to Packagist.

Reference

Comments

You need to login to comment.