Upgrading from drupal 8 to drupal 9 | How to upgrade drupal 8 site to drupal 9 using composer

As we know that, drupal 8 has end of life in November 2nd, 2021. there are very few day are left to upgrade the website from drupal 8 to drupal 9.

So, we are upgrading drupal 8 website to drupal 9 very quickly.

To upgrade and less like a migration, it can be completed in just five easy steps.

  • Make sure your environment is compatible with the requirements for Drupal 9.
  • Next, update core to the latest Drupal 8 version. Upgrades from 8.8 and 8.9 are supported to Upgrade drupal 9 or later version.
  • Update contributed projects until they are Drupal 9 compatible.
  • Remove deprecated API use in custom code.
  • Update Drupal core to Drupal 9. DONE!

Please note that not all community modules have become Drupal 9 ready.Please check patches and contribute patches where gaps arise.

Check if don’t have lastest version of Drupal 8, Upgrade drupal core 8.7 core to drupal recommended 8.9.19

Our current Drupal 8 version is Drupal 8.9.19
Our current Drupal 8 version is Drupal 8.9.19

We will perform step by step action and upgrade drupa 8.9.19 to Drupal 9.2.7

Prerequisites, Please run the below commands.

  • chmod 777 web/sites/default
  • chmod 666 web/sites/default/*settings.php
  • chmod 666 web/sites/default/*services.ym
  • composer update

Step 1: do below changes in changes in composer.json, if you have drush and devel then change ther version of both manually in composer.json and save it.

composer remove drupal/console
"drupal/core-recommended": "^9.2"
"drush/drush": "^10.6",
"drupal/devel": "^4.0",

Step 2: Run composer update command.

composer update

Issues 1: if you found below issues about an any module then just remove from composer.json and note down in separate file, So that we will upgrade it later one by one after up-gradation of core module file and run composer update again, do same active until it’s solve.

drupal/core 8.0.0-beta6 requires doctrine/common dev-master#a45d110f71c323e29f41eb0696fa230e3fa1b1b5 -> found doctrine/common[2.1.3, …, 2.13.x-dev, 3.0.0, …, 3.2.x-dev] but it does not match the constraint.

    – Root composer.json requires drupal/admin_toolbar ^1.25 -> satisfiable by drupal/admin_toolbar[1.25.0, 1.26.0, 1.27.0, 1.x-dev (alias of dev-1.x)].

Issue 2:   – Root composer.json requires webflo/drupal-core-require-dev ^8.6.0 -> satisfiable by webflo/drupal-core-require-dev[8.6.0-alpha1, …, 8.9.x-dev].

Solution: Just run below command to solve this, or change value of key require-dev with require-dev”mglaman/drupal-check”: “^1.1” in composer.json manually. and finally composer.json will be like below.

"require-dev": {
        "mglaman/drupal-check": "^1.1"
    },

If, above will not work, then leave it’s value blank, as like below.

"require-dev": {
    },

You can install this in your project using Composer as a development dependency like so:

composer require mglaman/drupal-check --dev


You can also install this globally using Composer like so:

composer require mglaman/drupal-check

Finally, Run composer udpate, it will update all your code to latest version of D9.

Update composer
Update composer

Step 3: Upgrade module one by one which we have removed while updating composer.

Upgrade Drupal Module to Drupal 9 compatible
Upgrade Drupal Module to Drupal 9 compatible

Step 4: run command lando drush updb -y , when it’s throw an errors solve one by one and run drush updb -y until it’s successfull.

 Issues 1: The config sync directory is not defined in $settings[“config_sync_directory”] 

Solve: this issues, just add config_sync_directory config setting in your settings.php files as below.

$settings['config_sync_directory'] = '../config/sync';

Issues 2:  You have requested a non-existent service “entity.manager”.  

Solution: just upgrade webform and webform_rest contributed module and run below command for the same.

composer require drupal/webform 
composer require drupal/webform_rest

Issues 3:

 [error]   (Currently using Incompatible modules The following modules are installed, but they are incompatible with Drupal 

9.2.7:

 * Simplenews

 * Content Api

 * Custom module

 * Vocabulary Api

Review the  suggestions for resolving this incompatibility [1] to repair your 

installation, and then re-run update.php.

Solution: Just follow below command, if you have contributed module like Simplenews and upgrade it by using composer e.g. : composer require drupal/simplenews or if you have custom module and change in .info.yml file of module like below, in place of core: ‘8.x’

core_version_requirement: ^8 || ^9

 Issues 4: Module kint has an entry in the system.schema key/value storage, but is missing from your site. <a href=”:url”>More information about this error</a>.

Solution: if you have system.schema key/value related issues for any module and use below command for the same, and pass module name inside delete function like below:

lando drush php-eval "\Drupal::keyValue('system.schema')->delete('kint');"

 Issues 5: [error]   (Currently using Missing or invalid module The following module is marked as installed in the core.extension. 

configuration, but it is missing:

 * kint

Solution: use below command for resolved the issues.

lando drush cdel core.extension module.kint

Note: after solve all issues, run below commands.

lando drush updb -y
lando drush cr
Finally, Upgraded From Drupal 8.9.19 to Drupal9.2.7
Finally, Upgraded From Drupal 8.9.19 to Drupal9.2.7

Pradip Mehta

I am a well-organized professional in Drupal Development and PHP web development with strong script handling knowledge or automation process with PHP. I have advanced computer skills and am a proficient multitasker.