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

3 thoughts on “Converting 7.x Drupal module to 8.x

  1. I think module will run but not good. Run because hook API drupal 7/8 is same. Not good because drupal 8 coding standards follow OOP style. So convert module from drupal 7 to 8 not easy as your post 🙂

  2. You made some decent points there. I looked on the net
    for more information about the issue and found most individuals will go
    along with your views on this site.

  3. Asking questions are in fact nice thing if you are not understanding anything completely, however this paragraph
    gives good understanding even.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s