XIO Experiences @DrupalCon - Part 2

oct 2014
-
Koen Cedeijn

So what are the options to port a Drupal 7 module to Drupal 8? Well there is the option of rebuilding your module from-the-ground-up in Drupal 8. There is also the option of copying your Drupal 7 module into your Drupal 8 project and start cleaning up all code and errors manually. Or you can use the Drupal Module Upgrader module and get somewhere halfway between rebuilding from scratch and manually cleaning your Drupal 7 module.

Porting to Drupal 8: "Close but no cigar" by Koen Cedeijn.

Intended audience: Developers

 

So what are the options to port a Drupal 7 module to Drupal 8? Well there is the option of rebuilding your module from-the-ground-up in Drupal 8. There is also the option of copying your Drupal 7 module into your Drupal 8 project and start cleaning up all code and errors manually. Or you can use the Drupal Module Upgrader module and get somewhere halfway between rebuilding from scratch and manually cleaning your Drupal 7 module.

 

I started some time ago with a build-from-scratch Drupal 8 module using a custom-build Drupal 7 module as basis, but was not able to get it fully up-and-running. When the sessions for DrupalCon Amsterdam were announced and one of them focused on porting your Drupal 7 module to Drupal 8 , 'yay!' and 'huzzay!' popped up in the head. The goal was to get this custom Drupal 7 module active and useable in Drupal 8 and I thought a 2-hour session would suffice to get at least a configuration page visible and to store some data in the database. Little did I know it was going to take a bit more time than 2 hours. You know what they say: Close, but no cigar!

 

Long story short: the first part of the lab-session started with an overview of module porting (with the help of the Drupal Module Upgrader module) and a rather extensive look at Drupal 8 API changes. The second hour provided some time to make a port from Drupal 7 to Drupal 8.

 

 

 

 

Porting to D8: not a ‘walk in the park’ (but the DMU helps)

 

So where porting your module from Drupal 7 to Drupal 8 isn't actually a walk in the park, the DMU module proved to be a helpful resource in doing so. It does not upgrade your module 100%, but it does as much as possible. The rest is up to you as a developer to clear out any remaining errors and re-test your module, until everything runs smooth and flawless. Where the first hour kept pouring waves and waves of data, how-to’s and API changes - which kept me from actually porting my own module - the second hour gave some more time and space to start with the actual porting - although I should call it 'attempts' in porting - instead of completely rebuilding your Drupal 7 module. I mainly used, or rather needed, the second hour to get my composer / drush set-up somewhat right. Lucky for me I got to ask the available DMU module developers about errors I already encountered.  

 

Conclusion: I didn’t really get what I hoped for from this lab-session - which was a working port of a Drupal 7 module - but I did get a few pointers and directions on building a Drupal 8 module, how to make use of the Drupal Module Upgrader and the usefulness of incorporated automated testing inside your module. Now go get me a lighter so I can light up this cigar!

Watch the first half of the session here.  

 

Koen Cedeijn
koen@xio.be

 

---

About "XIO-experiences @DrupalCon":

The XIO team had something to look forward to this summer: DrupalCon was coming up! It’s our annual tradition to go to the conference. DrupalCon 2014 took place in Amsterdam and featured the launch of the Drupal 8 beta. To get the most out of their visit, each team member wrote a small report about their favourite session... for knowledge sharing, inspiration and fun! Read more about their findings, insights and tips that might be useful to you as well...

More experiences are coming up!