GoAdmio

composer

Install Composer (the PHP dependency manager) from the operating system's package repositories

On this page: Overview · Quick start · Syntax · Output · Examples · Troubleshooting · Details · See also


Overview

Composer downloads and updates the PHP libraries that a website needs, such as the ones used by Laravel, Symfony, and many WordPress tools. /go/composer installs it on the server so that you, or GoAdmio's own commands, can run composer from the command line.

It installs the package that comes with the operating system. It does not download Composer from the Composer website.


Quick start

/go/composer

Syntax

/go/composer

The command takes no arguments. Anything you type after it is ignored, and is only written to /var/log/go/composer.log with a timestamp. Run it as root.


Output

The command shows a progress bar titled Installing Composer. The package manager's own messages can appear too.

There is no final message. Check the result with:

composer --version

On an operating system that is not listed below, the command does nothing and prints nothing.


Examples

# Install Composer
/go/composer
# Check that it works
composer --version
# Install a site's PHP libraries, running as the site's own user (use the account's username)
cd /home/example.com/www
sudo -u example.com composer install
# Review recent calls
tail /var/log/go/composer.log

Troubleshooting

Symptom Likely cause Fix
No match for argument: composer (AlmaLinux, Rocky, CentOS, Red Hat, Fedora) The repository that holds Composer is not enabled. Enable an extra repository such as EPEL or Remi, then run again.
Unable to locate package composer (Debian, Ubuntu) The package list is old, or the repository that holds Composer is off. Run apt update. On Ubuntu, enable the universe repository.
Could not open lock file or Permission denied (Debian, Ubuntu) The command was not run as root. Run it as root.
Nothing happens and nothing is printed The operating system is not one of the supported ones. Install Composer by hand.
composer: command not found after the install The install failed, or your shell has not seen it yet. Run which composer, or open a new session.
Do not run Composer as root/super user! Composer warns when it runs as root. Run it as the site's own user, as in the example above.
Composer uses the wrong PHP version The system's default PHP version is used. Run it with the PHP you want, for example php8.3 $(which composer) install. See defaultphp.
A library needs a newer Composer The package is the version the operating system ships, which can be older than the latest release. Install the latest version from the Composer website instead.

Details

What it does

  1. Records the call in /var/log/go/composer.log.
  2. Shows the progress bar Installing Composer.
  3. Installs the composer package:
    • AlmaLinux, Rocky Linux, CentOS, Red Hat, Fedora: dnf -y install composer
    • Debian, Ubuntu: apt -y install composer, without any questions
    • Any other system: nothing
flowchart TD
    A["composer"] --> B["Show progress bar"]
    B --> C{"OS"}
    C -- "Red Hat family" --> D["dnf install composer"]
    C -- "Debian or Ubuntu" --> E["apt install composer"]
    C -- "Other" --> F["Nothing happens"]

Good to know


See also

Command Description
vendor Install or update Composer vendor dependencies
installphp Install a PHP version with its extensions and PHP-FPM service
defaultphp Show or change the server's default PHP version
multiphp Change the PHP version of one domain or all domains
extension List, install, or remove a PHP extension across every installed PHP version
github Deploy GitHub repositories into site directories
package Install all base packages required by GoAdmio