• Edit
  • Delete

PHP Composer

https://getcomposer.org/doc/01-basic-usage.md

Usage

Require a new package

Adds the latest stable package to composer.json and composer.lock, downloads and installs it.
Also updates an existing package to the newest version regardless of the version set in composer.json (e.g. "sensiolabs/security-checker": "^4.1" to 5.0)

  • composer require webmozart/assert

Show installed packages

  • composer show

Install all defined packages

Installs or updated all packages as defined in the composer.lock file, eg. on production server

  • composer install

Update all defined packes to the latest version

As defined in in composer.json. Most of the time versions are given using the caret "^" operator.
Updates composer.lock file with new versions.
"webmozart/assert": "^1.3" means Install any minor version < 2.0
@see https://getcomposer.org/doc/articles/versions.md

  • composer update

Note: if you experience problems during update (with auto revert of composer.json) try to do all changes directly in composer.json at once and than composer update.

Config and Definitions

List of all required packages and versions:

  • composer.json

Lock file to ensure exactly the same versions all over the project (dev, testing, production)

  • composer.lock

Install on Ubuntu 16.04

as root

Install on Ubuntu 14.04

https://www.digitalocean.com/community/tutorials/how-to-install-and-use-composer-on-ubuntu-14-04

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

 

Run it

  • Change into directory
  • composer install