Composer User Guide

Useful Configurations

# Add composer global install location to PATH.
vim ~/.profile

# set PATH so it includes composer bin if it exists
if [ -d "$HOME/.config/composer/vendor/bin" ] ; then

Switch to China Repo

It's difficult to use global repository in China, try below configuraiton before execute any composer command:

# Switch to China repository mirror
composer config -g repo.packagist composer

# Remove China mirror
vim ~/.config/composer/config.json # Check and remove related configurations.

Local proxy

sudo apt-get install -y proxychains

vim /etc/proxychains.conf

socks5 3080

Useful Commands

# Update dependencies per composer.json.
composer u

Useful Cases

Drupal 8

composer create-project drupal-composer/drupal-project:8.x-dev d_drupal_8_wefmd --stability dev --no-interaction
Author: njun
njun's picture
Updated: 2019/11/02