Topic
Last updated August 23, 2017

Drupal 7 module and theme developers setting out to update their code to Drupal 8 can benefit a lot from mapping what they already know about Drupal 7 to the way that they accomplish the same thing in Drupal 8. This generally involves picking a Drupal 7 pattern and then browsing through change records, and using tools like Drupal Module Upgrader to help identify the Drupal 8 equivalent.

We also recommend taking the time to familiarize yourself with Drupal 8 features like events, plugins, and services -- at least enough to recognize which pattern is appropriate for different types of problems. This will help you spot instances where there either isn't a direct Drupal 7 to 8 path, or where Drupal 8 might provide an updated way of accomplishing something.

Example tasks

  • Update a custom Drupal 7 module so that it works with Drupal 8
  • Convert a PHPTemplate (.tpl.php) file to Twig (.html.twig)

Confidence

Beware of any tutorials or documentation showing before/after comparisons with Drupal 7 code from before Drupal 8 was released. Drupal APIs continued to change up until it was released, though many of these older tutorials are still accurate. We recommend spending some time learning current best practices so that when you encounter specific solutions you'll have a better chance to correctly gauge their accuracy.

Drupalize.Me resources

  • What's New in Drupal 8?
    • This collection of videos looks at most of the major changes between Drupal 7 and 8 and will help you transfer your existing Drupal 7 knowledge of how to accomplish things into Drupal 8.
  • Object-oriented PHP topic
    • Drupal 8 makes use of many object-oriented PHP (OOP) patterns, so if you haven't done any OOP programing with PHP you should first brush up on those skills.
  • Drupal 8 Module Development Guide
    • Porting modules to Drupal 8 requires learning about the new ways that modules interact with Drupal via routes, hooks, events, plugins, services, and more, as well as how to use all of the major APIs.
  • Drupal 8 Theming Guide
    • Porting themes to Drupal 8 requires understanding the Drupal 8 theme system, Twig, and asset libraries.
  • Twig topic
    • Twig is the new template language that replaces Drupal 7's PHPTemplate.
  • Coding Standards topic
    • Applicable especially after you've gotten started porting your code. We've found that using tools like phpcs to check for coding standards violations in your Drupal 8 code is another good way to highlight things that have been improperly converted.

More Guides

We have guides on many Drupal skills and topics.

Explore guides

External resources

  • Change Records (drupal.org)
    • If you've got questions about what happened to a specific hook, function, or way of doing things search through the change records for an answer. Most change records show before and after examples of specific code snippets. Make sure to also review those that are still in a draft state.
  • Drupal Module Upgrader (drupal.org)
    • This module works in combination with Drush, and Composer in order to scan your Drupal 7 code and make suggestions on how to upgrade it.
  • Drupal Twig Conversion Instructions (.tpl.php to .html.twig) (drupal.org)
    • Step-by-step instructions that were used for converting core functions, which can also be used by anyone who needs to covert to Twig.
  • Converting Drupal 7 modules to Drupal 8 (drupal.org)
    • This guide contains a number of different walkthroughs showing how to convert various elements in a Drupal 7 module. While you can't always follow it step-by-step and be successful we've found it to be a useful place to start tracking down what is necessary to incorporate some of the bigger and more conceptual changes.