Warning message

Documentation is currently being migrated into the new system. Some pages might be temporarily missing, and some guides might appear empty. Thank you for your patience while we are improving Drupal.org documentation.

Converting Drupal 7 modules to Drupal 8

This guide provides information and specific steps for upgrading contributed and custom modules from Drupal 7 to Drupal 8. Drupal Module Upgrader can do some of this automatically for you, covering many API hooks.

Should I start upgrading now?

Yes! Drupal 8 was released on November 19th, 2015.

Likely information to apply: a large list of Drupal 8 module and site development resources and videos at drupalize.me. PSR-4 autoloader patterns are used in Drupal 8. All change records.

See also converting themes to Drupal 8: (as it's likely you will need theme features as well as module API changes)

Before you start: Setting up a Drupal 8 module dev environment

Also see the full Drupal documentation for creating a custom Drupal 8 module.

Step 1: Convert mymodule.info to mymodule.info.yml

Before we begin replacing any code, we need to convert the module's .info file to a YAML file so Drupal 8 will recognize it. The easiest

Step 2: Convert automated tests to Drupal 8

Note: If the module does not have an automated test suite, skip to step 3.

Step 3: Convert hook_menu() and forms

This page is still under development.

Step 4: Convert Drupal 7 Variables to Drupal 8 Configuration

In Drupal 7 and before one of the common ways of storing settings was using variable_get() and variable_set(). In Drupal 8 these have been

Step 5: How to upgrade D7 variables to D8's state system

Old-style Drupal Variables (formerly controlled with variable_set and variable_get) need to be converted to Drupal 8's new configuration

Debugging Drupal 8 module upgrades

This page is still under development.

Resources and tutorials

This section of the Drupal 8 module upgrade guide provides examples, tutorials, and other resources for upgrading from Drupal 7 to Drupal 8.

D7 to D8 Upgrade: Generated HTML

Core CSS classes

D7 to D8 tutorial: pathinfo module

This is a live step-by-step tutorial of my process of porting pathinfo module form Drupal 7.x to Drupal 8.x as part of the global sprint

D7 to D8 upgrade tutorial: Pants module

This is the hands-on companion to the Pants module upgrading tutorial. This page contains two presentations, one from Sydney and another

D7 to D8 upgrade: fields, widgets and formatters

Why not try the example module explained on this page yourself? Download

D7 to D8 upgrade tutorial: Convert hook_menu() and hook_menu_alter() to Drupal 8 APIs

The new systems replacing hook_menu()

WSCCI Conversion Guide

This guide is a basic tutorial for the process of converting legacy page callbacks to new-style controllers. It is not a guide for porting

WSCCI Conversion Guide - Pass 1

1. Leverage the new routing system

WSCCI Conversion Guide - Pass 2

Dig deeper into our new controller class

WSCCI Conversion Guide - Pass 3

Named parameters in the router

WSCCI Conversion Guide - Best practices

Separate controller objects for different return types