jordankaiser
2/28/2019 - 4:37 PM

Composer

Composer

General composer documentation.

Adding new library.

Add a new library to composer.json and composer.lock. This will install it as well.

If you are working on a subcheckout you will need to make sure every other sub-checkout has the lib installed by updating their composer files then runnin composer install.

composer require [library/name]

# Real example:
composer require drupal/link_field_autocomplete_filter

Installing

If there is not a composer.lock file present composer will install the libraries and create one.

If there is a composer.lock file present it will install libraries according that that.

Updating

Keeping semantic version

Update a module while respecting the semantic versioning.

composer update drupal/webform

Changing semantic version

Update a module to a different semantic version. This will automatically update composer.lock.

composer require drupal/webform:dev-5x

Uninstalling

First uninstall using through the CMS. Then composer. You do not need to specify the version number.

composer remove drupal/pathauto

Updating on a new environment

  1. Push db/files/code from dev.
  2. svn update on target environment
  3. composer install
  4. drush updb
  5. fixperm .

Misc

Sometimes during composer install if a module had a patch but no longer composer will ask how it should handle code changes that patch caused in the effect module. You can almost always choose to overwrite that code.