Drupal 8 module development #1 – kicking off
This is the first of several on-going blog post series which aim to educate on the process of porting modules to Drupal 8 with real life examples by porting a popular Drupal 7 module to Drupal 8.
I’ve been following Drupal 8 development for quite a while, during which I helped a bit with the issue queue, posting some patches and did some general sanity testing to see what’s the buzz all about. I’m a firm believer in getting your hands dirty if you really want to know what’s going under the hood, and sometimes it’s just not enough to “read about it”. So with that said, I figured I’ll pick myself some non-migrated yet Drupal 7 module and start working on that. That module turned out to be Global Redirect which isn’t a terribly complex module so it makes a good starting point.
After doing some good progress with the module, I have e-mailed Thomas, the module’s maintainer and started collaborating on the Drupal 8 port together with Francisco and we’re on our way to get that module up and running for Drupal 8. In doing this, it was important for me to port the module with a sequence of logically incremented commits which are building-up the module’s port together so this will be easier for new comers to figure out from the commit diffs how the porting process begins.
Getting your hands dirty: the .info file
To kick-off this series of how to port a Drupal 7 module to Drupal 8 I will begin with a short and very focused area – the module’s info file. The module’s .info file purpose is very much like Drupal 7′s, provide some basic metadata about the file. The difference is that Drupal 8 version is expecting to find the YAML version of the file.
The structure of the .info file is very similar to that of Drupal 7 and a typical content would look like this:
name: 'Global Redirect' description: 'Searches for an alias of the current URL and 301 redirects if found. Stops duplicate content arising when path module is enabled.' core: 8.x configure: admin/config/system/globalredirect package: 'Path management' type: module
While YAML syntax is used to structure this file it is also possible to use PHP or another (meta) language. As you can see, the module’s .info file is pretty basic and easy to get going.
Popular reasons for the module not showing up in Drupal 8:
- You don’t have the .info file exists
- You don’t have the directive type: module in the .info file