An introduction to the Drupal Features module

11 September 2014
Authored by: 
Kuriakose Kurian

A Feature is a special kind of module which consists of generated code, created via the admin UI, that moves the configuration from database to code. Installing the Features module adds no new functionality to your site and, from a visitor’s perspective, the module does not allow your site to do anything that it couldn’t do before you installed it. 

So, what is the purpose of the Features module?  

Purpose of Features module

The Features module does one simple thing. It allows you to take site configuration settings and store them as a file, as a sort of mini-module, which allows you to do two things:

  1. re-use configuration settings; and
  2. add configuration settings to version control.

Re-using configuration settings

With Drupal you can create a website with minimal coding (even no coding). Most of the time you have to do the same configuration task again and again. This repeated process is something you need to do if you have to manage multiple Drupal environments (Dev » Staging » Production).

Sometimes, you may need to create similar functionalities for a couple of different projects. For example, in one of my recent projects I needed to create a Banner content type and then create an associated view with block and page displays. This would have been a tedious and boring job if I was forced to do it again and again for different projects or for a project with multiple environments.

So, the advantage of using Features modules is that it allows you to save your ‘news’ content type and associated view as a mini-module that can be re-used on another site.

I’m mainly using Features module for the Drupal project with a development procedure where sites are built on a development server, then moved to a staging server for testing, before finally being moved to a production server. The Features module saves me having to go through all the clicking to re-create the content type and view every time I need it

Adding configuration to version control

The Features module allow you to save the configuration details in files rather than database; you can save your web applications configuration features to version control system like GIT or SVN.

Another advantage of using the Features module, and storing these features to a version control, is to recover the site from an accidental change. For example, if someone accidently deleted a view then you can retrieve the original view by matter of few clicks  

How to create a Feature mini-module

To learn how to create Features modules, visit the community documentation here.

Features future in Drupal 8

I believe and expect most of the Features functionality will port to Drupal 8 core as part of Config Management Initiative and specifically, the concept of the 'activestore' and 'datastore' architecture etc. Here are a few useful links to learn more about Features module for Drupal 8.