Converting 7.x Drupal module to 8.x


drupal8_release_date_confusion

This is PART – I of creating module in Drupal8.

As we all know Drupal community are working very hard in development of Drupal8. So, I thought of writing about converting Drupal 7.x module to Drupal 8.x. Obviously porting to D7 module to D8 module will start when D8 core will get stable. But I was just curious to understand the changes made by community in D8 so I thought to take a dive in developing modules in D8 and along with that learn the changes with some coding , which probably will help at the time of module contribution for D8.

If you are not familiar with setting up D8 instance in your local machine then probably you should go through my earlier blog on Drupal8.

here’s the link :- https://beautiful7mind.wordpress.com/2013/02/11/whats-new-in-drupal-8-and-how-you-can-contribute

So, we will create one custom module in D8. Our module name is “alien”.

Steps to follow:-

  1. Create directory in modules . Note that now the directory structure of D8 core is changed . So , we will create all custom module in “drupal/modules/custom/”. Under custom directory create new directory that is your module directory name it “alien”. It will look like “drupal/modules/custom/alien”.
  2. Create some files in your alien directory  :-
  • alien.info.yml – [earlier .info file extention is change to .info.yml. If you give .info extension to your file your module will not be understood by Drupal8 core.]
  • alien.module – [contain code for doing some thing in site]
  • alien.install – [contain code for doing some thing in database of site ]

Now we will open file “alien.info.yml” in some editor and add below details into it.

name : alien
description : This module is to understand module development for D8.
package : core
version : VERSION
core : 8.x

That’s it. Save your alien.info.yml file. Now go to your site and Go to > Menu > Extend  here you are able to see your module “alien” in module list.

Hooorraaah it worked 🙂

Advertisements