How to update Drupal site with composer

Drupal update status
Drupal site update status

Introduction

Keeping your Drupal website updated is essential for security and stability. As a modern web application, Drupal relies on a powerful dependency manager called Composer for handling modules, themes, and core updates. This guide will walk you through the process of using Composer to efficiently update your Drupal site, ensuring it remains secure and performs optimally.

Setup:

Web server running on Ubuntu 18.04, 20.04, 22.04, LAMP stack
Drupal 8,9,10,11
Installed Drush, Composer

 

What is Drupal?

Drupal is a free, open-source content management system (CMS) that provides a flexible framework for building a wide range of websites, from simple blogs to complex corporate platforms. Its strength lies in its modularity, which allows developers to add functionality by installing and enabling thousands of available modules and themes.

 

Why Updates Are Important

Regularly updating your Drupal site is critical for three main reasons:

  • Security: Updates often include patches for vulnerabilities that could be exploited by attackers to compromise your site, steal data, or inject malicious code.
  • Performance & Stability: Updates fix bugs and improve performance, ensuring your site runs smoothly and reliably.
  • New Features: Core and module updates often introduce new features and enhancements, allowing you to take advantage of the latest web technologies.

 

Solution

The entire update process for our Drupal site will be managed by Composer, which we'll initiate with a single command to handle all necessary core, module, and theme updates.

Always back up your entire site before starting the update process.

    composer update

 

Execute the update process on your Drupal site.
composer update

Run the update on your Drupal site.

Full Drupal update using Composer
Full Drupal update using Composer
Finishing the update process
drush updb
drush cr

Finishing the update process by running this 2 commands. 
drush updb - to implement required database changes
drush cr - to clear / rebuild caches

 

Summary

Using Composer is the recommended way to manage updates for a modern Drupal site. This process not only keeps your core, modules, and themes up-to-date but also ensures all their dependencies are handled correctly. By regularly running Composer commands and following up with database updates and cache clearing, you can maintain a secure, stable, and high-performing website.