Composer tips and tricks

Last modified: 
Monday, 3. February 2020 - 5:37

Composer without root

Run this in ~/composer: curl -sS | php

Put this in .bashrc: alias composer="php ~/composer/composer.phar"

Install Drupal 8 With Composer In Custom Web Folder

composer create-project drupal-composer/drupal-project:8.x-dev my_site_name_dir --no-interaction --no-install
Adjust web folder in composer.json file and then run "composer install".

Check available versions of a package

composer show package_name --available

Multiple Package install

Separate packages with space.

For example: composer require drupal/package_name_1 drupal/package_name_2

Debug Composer

To see why a specific package is not able to install, use "why". Example:

composer why -t drupal/file_mdm_exif

Composer And Drush

If you use composer to update drush, you might get a very new drush version that won't work in your installation and you will get errors like: Bootstrap failed. Run your command with -vvv for more information.  

The solution might be: rm -Rf vendor/drush or composer remove drush/drush and then reinstall drush