Update Drupal core and contributed projects
Composer
List outdated packages
composer outdated "drupal/*"
Update Drupal core
For recent Drupal setups, based on drupal/core-recommended
composer update "drupal/core-*" --with-all-dependencies
For other cases, read more on Drupal.org (opens in a new tab).
This is valid for non major version updates. A new section will be added for major version upgrade specifics (example Drupal 9 to 10). You can also find documentation on Drupal.org (opens in a new tab).
Contributed projects
Update with
composer update drupal/<project_name> --with-all-dependencies
Troubleshoot
Some common issues.
Memory limit
Run Composer with an environment variable to increase the memory limit. Example for no limitation:
COMPOSER_MEMORY_LIMIT=-1 composer update drupal/<project_name> --with-all-dependencies
Packages conflict
Check why a particular version is not installed
composer why-not <vendor>/<package> <version>
Project not compatible with a major Drupal version
There can be patches to apply, check also the Drupal's Lenient Composer Endpoint (opens in a new tab) for more info.
Patches
If you have patches, depending on the codebase change, they might not apply anymore. You should check the issue the patch was created for and see if
- It is still needed: the patch was committed to a release or the dev branch. The issue is closed in this case. If it's on the dev branch, you have 2 options: require the dev version or still apply the patch until it makes it to the release.
- There is a new patch available, usually a "re-roll" to comply latest codebase.
- It still needs a re-roll, then you can contribute it (opens in a new tab).
Tip: to quickly find the issue, it is usually nice to have it in your composer.json file, like this:
"extra": {
"patches": {
"drupal/core": {
"#Issue number - Issue title": "https://www.drupal.org/files/issues/issue-1.patch"
}
}
}
More info about applying a patch.
Update the database and the configuration
When doing codebase update with Composer, chances are that there could be schema updates, so it's a good idea to run the database update and clear the cache.
drush updatedb
drush cache:rebuild
Some configuration changes can also be applied, run then
drush config:export --diff
and commit it in your repository, it will be used for the deployment.
The --diff
is optional but helps to review the changes.
To deploy, if you are unsure about the sequence of the commands to run, have a look at the Drush deploy command (opens in a new tab).
More info about deployments to be provided in Continuous Integration and Delivery (CI/CD).