Converting 7.x Drupal module to 8.x


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 :-

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  :-
  • – [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 “” 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 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 🙂


Building maps using Openlayers in Drupal 7

Implementing maps in Drupal7 is not easy as it was in Drupal6 using Gmap but Gmap module is not developed for Drupal7. I was working with maps in Drupal7 and personally I felt that there are less documentation on maps in Drupal7. So, I thought to write this blog which can probably help my readers in implementation of maps. Related to implementation luckily we have Openlayers module in Drupal7.

Openlayers with maps, what sounds like the small task of showing some nodes on a map with the following collection of modules and dependencies:

  • Geofield : which hold the geo coordinates in our content
  • Address field: to hold postal address in our content
  • Geocoder: to convert address data into geographical data
  • geoPHP: Geocoder dependency
  • Openlayers

With some additional dependencies

  • Ctools
  • Views 3

Step 1: First you have to install above module and enable them included with Openlayers and its sub modules

  • openlayers_ui
  • openlayers_views

Step 2: Create content and add following fields

  • Addressfield : Postal address , zipcode , city
  • Location : field_type – Geofield , Widget – Geocode from another field


Address field will store your postal address of your business and geofield will take those address in location field and fetch geo coordinates of all businesses.


Step 3: Creating a Map

Openlayers come with many configurable option. I will describe basic options which you need for creating map. We need a base layer which is our map with some additional behaviors and styles on it. Secondly, Openlayer overlay which we will setup using views later.

Getting started with creating map

Go to structures > Openlayers > maps. Click add map and fill all details. Your map details should look like below.


Configure layer & style for your map.


Configure some behavior for map.



Now we are done with creating map which we will use for displaying data on it later.

Step 4: Creating Openlayer Overlay or you can say map view.

We need two things

  • Openlayer overlay to display data on map
  • Page or block to display map

Go to structures > Views > add new view .

Values for view

  • Show : Content
  • of type : Business information
  • create a page : Checked

Click on continue & edit. Here we will change some things in our view.

Add these values to your view

  • Format : Map > business map > Apply(all display)


  • Add Fields : 1) Title 2) Location . You should also set path of you page.

Now we will change some settings of our Openlayers overlay. Click on settings side by Format Openlayers Data Overlay | Settings.

  • Map data sources > WKT
  • WKT field > content : Location
  • Title Field > content : Title


What just we did ?

We created our map and added overlay for our data to display on map using views.

Last Step

We will add this Overlay to our map which we created earlier . Go to Structures > Openlayers > Maps > business map > layers & style . You probably see your view their in list . Just enable them so this map will use overlay for displaying content.


That’s it at this point we had a page available containing map with overlays displaying data when you hover them.


Thanks to Sonali , Anirudha , Chetan for reading draft of this.

Doxygen and your project

This blog will give you practical knowledge of why and how you can use Doxygen . You have heard this word Doxygen many times but don’t know what exactly it is ? Or may be majority didn’t hear about this technology. So, now it’s time to get friendly with Doxygen and make your life easier. So let’s start.

Tell me what Doxygen actually is ?
Doxygen is a new and emerging technology. It’s a system which allows you to make documentation of your different projects running on C , C++ , Java , Python , PHP , Objective-C , IDL (Corba and Microsoft flavors) , Fortran, VHDL , C#, D.
Doxygen is open source technology which runs on almost all Unix flavors. Executables for Windows are also available.


Why should I use Doxygen in my project ?

Doxygen has many advantages. Some noted below.

  1. It can generate on-line documentation browser in HTML or an off-line reference manual in LATEX from documented source files.
  2. It also generate your documentation in RTF (MS-Word) , Postscript, hyperlinked PDF ,compressed HTML , and Unix man pages.
  3. You can make documentation of any code structure (including framework , CMS , complex projects ) from its undocumented source files. So instead of googling every time you can directly dive into code structure documentation and understand relationships between classes , methods etc.
  4. You can also visualize relationship between your code elements including dependency graphs, inheritance diagrams , collaboration diagrams . And hey good news is all these things get generated automatically with no pain.
  5. It actually speeds up the development process of your project when you are working on big code architecture like Drupal or Django etc.
  6. Doxygen add plus point in your project when you delivering project to your client by providing technical documentation with project.
  7. I believe Doxygen not only help to clients but in many software development processes (Development, Testing , Maintenance , Implementation , Deployment )
How can i install Doxygen in my linux machine ?

Step 1: Download Doxygen source from here doxygen or you can just write this command in your terminal .

sudo apt-get install doxygen

Note:- Makes sure apt-get is only for Ubuntu and Debian please use as per your Linux distribution.(fedora- yum , opensuse – zipper )
Step 2:After downloading source tar package of Doxygen . Extract it by terminal

tar xf doxygen-$VERSION.src.tar.gz

If you have installed it by “apt-get” then skip this step and directly switch to running and configuring Doxygen with your project.
Step 3: Run the configure script :

cd doxygen-$VERSION

sh ./configure

Step 4:Compile the program by running make:


Step 5:Optional : Generate the user manual

make docs

Step 6: After the compilation of the source code do following to install Doxygen

make install

Note:- Make sure you are in root or maybe it will give you error in making directory or executable in /usr/bin , /usr/bin/x11/

Well done you have installed Doxygen!

Note:- For more advance installation instruction you can check out here : Advance installation

How i can give some oxygen to my project ? :- Configuration

 Step 1: Go into your project directory and run this command

doxygen -g [configfile name]

Note: If you do not give any file name then Doxygen will generate “Doxyfile” by default.
Step 2: Now just open your configuration file and edit as per your project andprogramming language you are using .
Step 3: Tell doxygen about your project configuration

doxygen [configuration file name]

Step 4: check your documentation in /html or /man depends what type of documentationyou are generating .
Here you can download Doxygen config file for PHP project from my Github repository : config file

How can i use Doxygen in understanding Drupal CMS(PHP based) ?

Scenario 1:

I was working on Drupal project and i wanted to know all functions, classes , hooks etc used in Drupal and how exactly i can modify them as per my project requirement. I came to know about API module in Drupal and it’s good but i was not satisfied because of three things :
  1. It was slow . I have to again and again do lots of clicks.
  2. I have to check security updates as it was released again and again .
  3. I didn’t have choices of generating my documentation in different formats whichshould be understandable by my user.
I need some system which actually generate documentation of Drupal source code and able to explain me all relationship between classes etc.So API module and Doxygen both have their own objective and viewpoints. API module let you know what all methods , hooks you can use in Drupal .But Doxygen generated documentation of your undocumented source code of Drupal off-line and give you user friendly docs of source code with various relationship diagrams. This is basically one feature of Doxygen but if you are working on large CMS or frameworks it will make your life easier. you can modify comments as you want and document them.
 So some things i like to include here about what i observed after creating my documentation of drupal source code .
1. My documentation was fancy , structured and understandable .
2. Documentation have Indexes and it was browsable.
3. Doxygen documented all files, namespaces, packages, classes, structs, unions, templates, variables, functions, typedefs, enums and defines.
4. It generated all my class and collaboration diagram in HTML and LATEX.
5.It grouped all my entities in modules and created hierarchy of modules.
6.Generated all list of members of a class along with their protection level.
7.Automatically generated references to documented classes , files , members and namespaces , global variables , functions typedefs , defines and enumerations .
8. References to my base/super classes and inherited/overridden members are generated automatically.
After getting all this information my development process became easy.This is how
Doxygen gave me oxygen in this scenario and it was really cool.
You can check out my documentation of source code of Drupal 7 created using Doxygen 

Drupal documentation

Scenario 2:

How i used Doxygen after documenting my project?

  1. I have used dot tool of the Graphviz tool kit to generate include dependency graphs, collaboration diagrams, call graphs, directory structure graphs, and graphical class hierarchy graphs and it was beautiful .
  2. I configured references to documentation generated for other projects in a location independent way. So let say if i’m working on big and complex project and i created many documents for different components of project. At last i need to merge those documents in one documentation. Here Doxygen gave me flexibility by allowing integration of all documents together .
  3. I wanted to transfered my documentation from my office laptop to my personal laptop. In this thing Doxygen allow me to transfer all my documentation and search engine to my personal laptop without regenerating the documentation.
I hope this blog will help to folks who want some information for start using Doxygen .

I hope it will also help to project managers in making decision to use Doxygen in their projects .


Note: I will add Doxygen configuration files of different projects running on different programming languages in my github repository as i will do some more R&D on Doxygen working with other technologies.


Thanks to Sonali sambhus for reading draft of this.
References :-