Composer tips and tricks

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

composer show drupal/video_filter --available
name     : drupal/video_filter
descrip. : Filter to include videos from Youtube, Vimeo, YouKu, Google Video etc
keywords : 
versions : 1.x-dev, 1.0.0-alpha2, 1.0.0-alpha1, dev-1.x
type     : drupal-module
license  : GNU General Public License v2.0 or later (GPL-2.0-or-later) (OSI approved)
source   : [git] a12c46181fc32bfb0d465339f97f3a767fcb69f5
dist     : []  
names    : drupal/video_filter

Then download dev version: composer require drupal/video_filter:1.x-dev

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

Last modified