Skip to main content

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) them for you.

Installation

We recommend installing composer in userspace, as this allows you to use a newer version than the one provided by Ubuntu.

  1. Download the setup file:
www-data@server:~$ php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
  1. Install composer:
www-data@server:~$ php composer-setup.php --install-dir=bin --filename=composer
All settings correct for using Composer
Downloading...Composer (version 2.1.3) successfully installed to: /home/www-data/bin/composer
www-data@server:~$ composer --help
Usage:
help [options] [--] [<command_name>]Arguments:
command The command to execute
command_name The command name [default: "help"]

Update

Run the following command to update composer:

www-data@server:~$ composer self-update
You are already using the latest available Composer version 2.1.3 (stable channel).