Skip to main content
Image
Update

Upgrading Drupal 8 with composer

Good afternoon everyone. Today we are going to go through the procedure of a Drupal 8 core upgrade. A lot of effort has been put into making this process easy today and not causing too many problems.

Before you start upgrading your Drupal, it is important to know the cycle of updates that are released.

  • Patch versions (8.0.1, 8.0.2, 8.0.3, etc.) will be released every month, fixing reported bugs and security holes. There have been cases in which these updates are released early due to serious bugs.
  • Minor versions (8.1.0, 8.2.0, etc.) will be released approximately every six months and will incorporate new features and hotfixes.
  • Long-term versions or LTS (8.0.0, 9.0.0) are versions that are released, as the name implies, for long-term support. Drupal 8 was released on November 19, 2015, while the next LTS version will be Drupal 9 and will be released in 2020.

Once we have learned the drupalero calendar, we can take action to update our website. Remember that it is necessary to have composer installed to manage the versions of the package and drush to perform the administration tasks in a faster way directly from the console. From my post I explain how to install both valuable utilities. There are other methods to update Drupal, but this is the most recommended today.

Updating our Drupal 8

First of all, we must check if there are updates available, this can be done from the administration interface of our portal (status report) or from the console with the following command:

composer outdated drupal/*

Once it is done and after a few moments of waiting, it will print a table with the package that needs to be updated, indicating the current version and the most recent version available. If the core appears, it is necessary to update it. It is also important to take a look at our composer.json, to verify our current Drupal version and to know if our upgrade will be to a patch version or to a minor version. If for example we want to upgrade from 8.5.0 to 8.6.0 it is necessary to replace in the composer.json the core version from "~8.5.x" to "^8.6".

To start, we will dump the database as a security measure in case something goes wrong (better to be safe...)

drush sql-dump backup.sql

The next step is to read the release notes of the released version, as there can always be cases in which some modules have undergone changes or it is recommended to act in some way in the update. It never hurts to be informed about why we are going to update our Drupal.

According to Drupal recommendations, in the next step it is recommended to put our website in maintenance. This can be done directly from the administration interface or with the following commands:

drush sset system.maintenance_mode 1 drush cr

And now let's go to the most important command, where we will update the Drupal core using composer, including its dependencies (usually symfony components, among others).

composer update drupal/core --with-dependencies

If the command does not work for us, it may be because our Drupal was assembled with composer/drupal-project, where the command will change a bit:

composer update drupal/core webflo/drupal-core-require-dev --with-dependencies

Finally, we will update the database (if there are updates) so that it is in accordance with the changes implemented in the package.

drush updatedb drush cr

Finally, we will only have to make our site active by deactivating the maintenance mode from the administration interface or with the commands:

drush sset system.maintenance_mode 0 drush cr

With this we would finish the process of updating our Drupal. Once we mechanize this process, it will be much easier and faster. Before finishing, it is advisable to check the status report from our administration interface to verify that everything went correctly.

Join the Drupal Sapiens Community

Save content that interests you, connect with others in the community, contribute to win prizes and much more.

Login or create an account here

Latest posts

Featured

Last news