{"id":15679792,"url":"https://github.com/grasmash/drupal8to9-upgrade","last_synced_at":"2026-03-14T11:10:30.095Z","repository":{"id":52627397,"uuid":"360241742","full_name":"grasmash/drupal8to9-upgrade","owner":"grasmash","description":null,"archived":false,"fork":false,"pushed_at":"2021-04-26T19:09:32.000Z","size":201,"stargazers_count":11,"open_issues_count":3,"forks_count":10,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-19T21:24:34.292Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/grasmash.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-04-21T16:48:00.000Z","updated_at":"2025-03-12T23:01:05.000Z","dependencies_parsed_at":"2022-08-21T08:10:39.873Z","dependency_job_id":null,"html_url":"https://github.com/grasmash/drupal8to9-upgrade","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fdrupal8to9-upgrade","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fdrupal8to9-upgrade/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fdrupal8to9-upgrade/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/grasmash%2Fdrupal8to9-upgrade/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/grasmash","download_url":"https://codeload.github.com/grasmash/drupal8to9-upgrade/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252860506,"owners_count":21815527,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-03T16:36:27.584Z","updated_at":"2026-03-14T11:10:25.044Z","avatar_url":"https://github.com/grasmash.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Upgrade Drupal 8 \u003e 9 in 20 Minutes\n\nThis repository contains an example Drupal 8 application to be used for the \"Upgrade Drupal 8 \u003e 9 in 20 Minutes\" workshop.\n\nTo upgrade this site to Drupal 9, proceed to the following directions.\n\n## Prepare for the Workshop\n\nThe \"hands on\" portion of the workshop will be performed in Acquia's recommended development environment, [Acquia Cloud IDE](https://www.acquia.com/products/drupal-cloud/cloud-ide). If you're already an Acquia customer you may use your existing [Cloud Platform application](https://cloud.acquia.com/a). In any case, you will be invited to join our \"Acquia Learning Services\" sandbox application where you are free to create a Cloud IDE for this workshop.\n\n1. When you receive an invite to the Acquia Learning Services application from Acquia via email, accept the invite. You will be prompted to [login or create an Acquia Cloud Platform account](https://accounts.acquia.com/sign-in), and you will then be prompted to accept the invitation for that account.\n1. On the [\"Acquia Learning Services\"](https://cloud.acquia.com/a/applications/11566968-0964-4659-9a21-6ef99adae3df) application on cloud.acquia.com, create a new Cloud IDE for yourself by clicking **Actions** \u003e **Create Cloud IDE** and give it a **Label** such as **Drupal 9 Upgrade Workshop**. Please only create **one** IDE, as the number available are limited. This IDE will be available for 3 days following the workshop.\n   ![image](https://user-images.githubusercontent.com/539205/115599148-407c6900-a2a9-11eb-97f4-8de9404fa4c8.png)\n1. The IDE will take 10-15 minutes to provision. You will see it listed alongside your other environments such as Dev, Stage, and Prod. In the mean time, feel free to peruse the [Cloud IDE Product Documentation](https://docs.acquia.com/ide/) to familiarize yourself with the user interface.\n1. Once provisioning is complete, click **Launch Cloud IDE** to login to the Cloud IDE. \u003cimg width=\"463\" alt=\"Screen Shot 2021-04-22 at 12 28 59 PM\" src=\"https://user-images.githubusercontent.com/332535/115774531-8fd49f00-a366-11eb-8319-5fe68d6ef6f0.png\"\u003e\n3. If you'd like, you can complete steps 1-3 in the \"Workshop Walkthrough\" below so that you join this workshop with Drupal already installed on your IDE.\n\n## Workshop Walkthrough\n\n### Set up your Cloud IDE with a Drupal 8 site\n\n1. Login to your Cloud IDE.\n1. Open a Terminal pane in the IDE browser tab by clicking **Terminal** \u003e **New Terminal**. You will start off in the **~/project** directory, which is where your Drupal application will live.\n   ![image](https://user-images.githubusercontent.com/539205/115598056-fd6dc600-a2a7-11eb-9b07-f1e365898981.png)\n\n1. Clone the codebase. In the Terminal pane of the Cloud IDE, Run:\n   ```bash\n   git clone https://github.com/grasmash/drupal8to9-upgrade .\n   ```\n1. Install all the necessary modules and libraries using Composer. In the terminal run:\n   ```bash\n   composer install\n   ```\n1. Now, install the Drupal site automatically using Drush. In the terminal, run:\n   ```bash\n   drush site-install -y\n   ```\n1. Your codebase (files) is all ready to go! If you do not, then click the \"Refresh\" button on the explorer pane of your IDE.\n   ![image](https://user-images.githubusercontent.com/673633/115936908-26cf5300-a45c-11eb-9c79-33710b6530fb.png)\n\n1. Now, you may login to the new Drupal site and validate that it is working as expected. In the terminal, run:\n   ```bash\n    drush user-login\n   ```\nHold the cmd key and click the link. This will open the your Drupal site in a new tab and log you in automatically. The site is called \"Drush Site-Install\" and has no content yet. You are now all set and ready to migrate your test site!\n\n   ![image](https://user-images.githubusercontent.com/332535/115776003-76345700-a368-11eb-9236-6fb8059992d6.png)\n\n\n### Add the \"Upgrade Status\" tool to your Drupal 8 site\n\nNext, we will download the [Upgrade Status module](https://www.drupal.org/project/upgrade_status). This will assist us with identifying what changes will be necessary to make our Drupal 8 site Drupal 9 compatible.\n\n1. First, we want to add Drupal core developer libraries and enable you to run tests. This is only necessary for migrating and doing development, so we will remove this later. In the terminal, run:\n   ```bash\n   composer require drupal/core-dev:8.9.0 --dev -W\n   ```\n\n1. Next, we will want to add the \"Upgrade Status\" module which will run tests and direct us on how to upgrade our Drupal 8 site and prepare it for Drupal 9! In the terminal, run:\n   ```bash\n   composer require drupal/upgrade_status\n   ```\n1. Now that we have the \"Upgrade Status\" module added to the site, lets turn it on. In the terminal, run:\n   ```bash\n   drush pm-enable upgrade_status -y\n   ```\n1. You should already be logged into your site from the previous section, but if you are not, run `drush user-login` and cmd+click the link to login.\n1. Visit `/admin/reports/upgrade-status` on the Drupal site. You can navigate there by first clicking \"Reports\" in the admin menu and then clikcing \"Upgrade Status.\"\n   ![image](https://user-images.githubusercontent.com/539205/115598426-6bb28880-a2a8-11eb-996e-f1e6ca758b79.png)\n\n### Upgrade Contributed modules\n\n1. Note on the \"Upgrade Status\" report that the Token module is listed as incompatible with Drupal 9. However, that notice also indicates under the \"Plan\" column that \"8.x-1.7+ is Drupal 9 compatible.\". We will therefore update the Token module to _at least_ 8.x-1.7.\n   ![image](https://user-images.githubusercontent.com/539205/115734335-9e678a00-a357-11eb-8997-5163313a8f2b.png)\n1. Remember that in Drupal's Semantic versioning for Composer, the canonical version 8.x-1.7 is transformed to `1.7.0`. We will therefore use a version constraint of `\"drupal/token\": \"^1.7.0\"` to instruct Composer to install a *minimum* version of Token 1.7.0. \n1. We can do this by using the same command above to add a module, but this time we will specify the version. **Switch** back to your IDE. In the terminal, run:\n   ```bash\n   composer require drupal/token:^1.7.0\n   ```\n1. Your codebase has now been updated! You will want to clear the cache in order to let the system see the updated module version. In the terminal, run:\n   ```bash\n   drush cache-rebuild\n   ```\n2. **Switch** back to your Drupal site, and reload the Upgrade Status report. You should see that Token has now been moved under a \"Drupal 9 Compatible\" heading and the row is green.  ![image](https://user-images.githubusercontent.com/332535/115777051-b34d1900-a369-11eb-9870-c8145fdb03ff.png)\n\nYour contributed modules are now Drupal 9 compatible!\n\n### Upgrade custom code\n\n1. The second module is an example custom module called `my_special_module`. This module is NOT Drupal 9 compatible. Lets enable the module so we can scan it. **Switch** back to your IDE. In the terminal, run:\n   ```bash\n    drush pm-enable my_special_module -y\n   ```\n1. Now we can check the status of the custom module. **Switch** back to your drupal site and refresh the Upgrade Status report. Check the row for **My special module**, and click **Scan selected**.\n   ![image](https://user-images.githubusercontent.com/539205/115738525-20a57d80-a35b-11eb-9c6d-47dc1bd1f7ca.png)\n\n1. The Upgrade Status tool has identified a few issues that we need to clear up. Click on the \"2 problems\" link for the \"My special module\" module:\n   ![image](https://user-images.githubusercontent.com/539205/115738683-4468c380-a35b-11eb-898c-ba040d91f753.png)\n\n1. You'll see some very helpful details on exactlly what needs to be changed in the module In this case, we need to replace a deprecated function and update the module's info.yml file to let Drupal know that it can be run in Drupal 8 OR 9:\n   ![image](https://user-images.githubusercontent.com/539205/115739800-38c9cc80-a35c-11eb-8505-b74258a5ced4.png)\n\n1. Lets make those changes! **Switch** back to your IDE. In the explorer pane, open the `docroot` folder, then the `modules` folder, and then the `custom` folder. You should now see the `my_special_module` folder. Open this one too.\n1. Lets fix the easy one first. Open the `my_special_module.info.yml` file and lets tell Drupal that this module works for both Drupal 8 and 9. In the file, change:\n   ```yml\n   core: 8.x\n   ```\n   To:\n   ```yml\n   core_version_requirement: ^8 || ^9\n   ```\nNow you can save the file by going to `File -\u003e Save` in your IDE menu.\n1. Changing the other issue is a little trickier, but not bad. The Upgrade Status tool told us exactly what needed to be changed, and where! The `drupal_set_message` function has been deprecated, and we are using it on like 9. Lets go ahead and make that change. Open the `my_special_module.module` file and change:\n   ```php\n   drupal_set_message(t(\"Welcome @name! You are a special person.\", ['@name' =\u003e $account-\u003egetAccountName()]));\n   ```\n   To:\n   ```php\n   \\Drupal::messenger()-\u003eaddMessage(t(\"Welcome @name! You are a special person.\", ['@name' =\u003e $account-\u003egetAccountName()]));\n   ```\nNotice that we are just changing the function a little, but the inside of the function remains the same. This is exactly what the Upgrade Status tool told us to do. Now you can save the file by going to `File -\u003e Save` in your IDE menu.\n1. Here comes the fun part! **Switch** back to your Drupal site, and re-scan the custom module once more in the Upgrade Status report. This time, it also moves down to the \"Drupal 9 Compatible\" fieldset! Congratulations - you just migrated your custom module from Drupal 8 to Drupal 9!\n\n### Remove our tools\n\nNow that our entire site is Drupal 9 compatible, we can remove some of the tools that we installed. **Switch** to your IDE again.\n\n1. Uninstall the \"Upgrade Status\" module. In the terminal, run:\n   ```bash\n   drush pm-uninstall upgrade_status\n   ```\n1. Now we can remove the \"Upgrade Status\" module completely. In the terminal, run:\n   ```bash\n   composer remove drupal/upgrade_status\n   ```\n1. We can also remove the core developer testing tools. In the terminal, run:\n   ```bash\n   composer remove drupal/core-dev --dev\n   ```\n\nAfter doing this, you'll see that the Upgrade Status report and module are both gone, and your site is back to the way it was.\n\n### Upgrade Drupal core.\n\nNow that all of our modules are Drupal 9 compatible, the last step is to upgrade Drupal core.\n\n1. We could do this using the composer command again, but it is actually pretty easy to manually make the change. **Switch** to your IDE. In the root of your explorer pane, open the `composer.json` file.\n   ![image](https://user-images.githubusercontent.com/539205/115598302-41f96180-a2a8-11eb-8896-bba917745afa.png)\n\n1. Inside that file, lets change the three references to Drupal 8.9 to Drupal 9.1 (or higher). Change:\n   ```json\n   \"drupal/core-composer-scaffold\": \"^8.9.0\",\n   \"drupal/core-recommended\": \"^8.9.0\",\n   To:\n   ```json\n   \"drupal/core-composer-scaffold\": \"^9.1.0\",\n   \"drupal/core-recommended\": \"^9.1.0\",\nNow you can save the file by going to `File -\u003e Save` in your IDE menu.\n1. We are getting closer! The `composer.json` file will tell composer to replace Drupal 8 core with Drupal 9, so lets have it update. In the terminal, run:\n   ```bash\n   composer update\n   ```\n1. Next, we need to clear the caches to be sure that everything sees the updated code. In the terminal, run:\n   ```bash\n   drush cache-rebuild\n   ```\n1. Finally, we need to update the database so that it can make any necessary changes. In the terminal, run:\n   ```\n   drush updatedb -y\n   ```\n1. **You're done!** To verify, **Switch** to your Drupal site, and go to **Reports** \u003e **Status report** and verify that your **Drupal version** reads 9.1.7 instead of 8.9.14!\n\n![image](https://user-images.githubusercontent.com/539205/116137281-5622d180-a6a1-11eb-9b0b-c92a7aa8a938.png)\n\n### Troubleshooting\n#### I get an error \"Your requirements could not be resolved to an installable set of packages.\"\nThis is caused by a typo in your composer.json, for example specifying `9.1.0` instead of `^9.1.0`. Check the results **carefully**... every character matters! :)\n\n#### I see notices when running `composer update` about Package container-interop/container-interop being abandoned\nDon't sweat it... this is coming from Drupal core because of one of its upstream dependencies; nothing you're doing wrong, and it's a harmless error.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrasmash%2Fdrupal8to9-upgrade","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgrasmash%2Fdrupal8to9-upgrade","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgrasmash%2Fdrupal8to9-upgrade/lists"}