Got a new web project? Request a quote

What is the features module?

Some time ago, a client asked me about the features module. He wanted to know what the features module is about and how it can help him with his project. Their set up was a pretty complex e-commerce application involving multiple content types and integration with 3rd party services. Yet, they were not using features and would manually replicate any changes from the developer's machine to the server. He was concerned about maintaining the site and how he could add some new functionality without breaking the existing configuration. My recommendation was that they start using features. He had not idea what it was so I wrote him an email explaining. This gave the idea of this blog post.

What is the features module?

The purpose of the Features module is to copy configuration setups from one drupal site to another. It creates "packages" of the settings that can be shared among different sites. Today it is used in almost every development workflow to deploy changes from one environment to the other. Drupal 8 comes with a more advanced functionality in core. It is called configuration management (https://drupalize.me/blog/201401/drupal-8-configuration-management-walk-...) . From the features project page in drupal:

Features provides a UI and API for taking different site building components from modules with exportables and bundling them together in a single feature module. A feature module is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its .info file so that it can be checked, updated, or reverted programmatically.

Why is feature so popular?

Drupal 7 stores every configuration setting in the database. This poses a problem when the developer wants to copy a content type or a view or some settings from one site to another. This is the problem that features try to solve. Features allow the developers to export those settings in files and then import them to another environment/site. You can think of features as special kind of modules. In drupal 8, thanks to the Configuration Management Initiative, every setting is stored in files. Keeping the configuration settings in files has many advantages:

    1. The configuration can be tracked in version control systems
    1. The configuration can be reused/shared
    1. The deployment workflow is greatly simplified.

This result in less bugs, less frustration, better quality and ultimately faster (=cheaper) results.

How do features work?

Assume that the developer creates a new content type and he wants to copy it to the development server. Here is what he will do with features: 1. He adds the content type to an existing feature (or creates a new one). features will automatically detect any dependencies (eg modules implementing the fields) 2. He downloads the features and copies it to the custom modules folder. Then he pushes it to the version control system. 3. The features module is pulled to the development site 4. The feature is enabled and the content type is automatically created. Now assume that he makes some changes to the content type. Here is how he copies to changes to the site: 1. Updates the feature using the features UI or using drush (this causes the feature to pick up the changes) 2. Pushes the feature to the live site 3. He reverts the feature in the live site so that the changes are activated.

Do I need it?

If you plan to deploy some new functionality for your web site then the chances are that you will need it. Having questions? use the comments section below or Contact me.