Composer

From XennisWiki
Jump to: navigation, search

Composer is an application-level package manager for the PHP programming language that provides a standard format for managing dependencies of PHP software and required libraries. [...] Composer runs through the command line and installs dependencies (e.g. libraries) for an application. [...]. It also provides autoload capabilities for libraries that specify autoload information to ease usage of third-party code. (Wikipedia)

Installation

Arch Linux

pacman -S composer

Debian

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

Windows

Download the Composer Windows Installer and run through the installation

Usage

Further information: Getting Started - Basic usage

Create a composer.json

{
  "require": {
    "abeautifulsite/simpleimage": "~2.5.5"
  },
  "require-dev": {
    "phpunit/phpunit": "7.4.*"
  }
}

Install the specified dependencies composer install

Install a package globally

Install a package

composer global require <package>

Optional: Add the Composer bin directory (for instance ~/.config/composer/vendor/bin) to the $PATH.

Remove a package

composer global remove <package>

See also

  • npm JavaScript package manager
  • bower JavaScript npm package manager

External links