composer

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
    PATH="$HOME/.config/composer/vendor/bin:$PATH"
fi

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 https://packagist.phpcomposer.com

# 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 127.0.0.1 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