Composer tool itself

Updated: 17 January 2023

Install Composer phar

curl -sS | php

Circumvent php memory limit

php -d memory_limit=-1 composer.phar install

Up / downgrade Composer itself

composer self-update --help
composer self-update --1
composer self-update --2

Composer in Docker

Updated: 17 January 2023

Require a new project as a dependency

docker run --rm \
    -v $(pwd):/app \
    composer/composer:latest \
    require slim/slim "^3.0"

Install all dependencies in a project

docker run --rm --interactive --tty --volume $PWD:/app composer install


Updated: 02 May 2023

The require command adds new packages to the composer.json file. A composer.json file will be created if one doesn’t exist. After adding/changing the requirements, the modified requirements will be installed or updated.


  • --update-with-dependencies (-w): Also update dependencies of the newly required packages, except those that are root requirements.
  • --update-with-all-dependencies (-W): Also update dependencies of the newly required packages, including those that are root requirements.

Update a single package

composer update doctrine/doctrine-fixtures-bundle

Remove package(s)

php composer.phar remove vendor/package vendor/package2

List all packages and their versions

composer show

Install package at a particular version

composer require drupal/commerce_pricelist:2.0-rc2

The install command reads the composer.json file from the current directory, resolves the dependencies, and installs them into vendor.

composer install

Deletes all content from Composer’s cache directories.

composer clear-cache