Turn Drupal into Lego Bricks with the Features Module
Drupal is doing a fantastic job with separating content, structure and design for websites. However, when it comes to developing a Drupal website, especially adding new features to an existing website, you will undoubtable run into issues that will require a lot of extra work.
Normal practice is to have a development server where you develop new features. Then you make a test implementation on a staging server. Finally, when everything have been thoroughly tested, you implement it on the production server.
During this process you will have to take extensive notes about everything needed for the new features to work properly. This includes, but are not limited to:
- Modules required
- Module configuration
- Changes to existing settings
- Theme modifications
The notes you are taking will work as an instruction guide for how to implement the new feature.
For small websites, such as Nutshell, with only one or a few people working on it, this is generally not a big problem. Not so for larger and more complex websites with many developers and designers involved. As the website grows, more time will go to making sure new features are implemented correctly, more time will go to testing it on the staging server, more time will be spent going over all the configurations to make sure everything is correct and so on.
This is due to the way content and configuration is mixed up in the Drupal database. There are no standard simple way to export the configuration for a new feature in Drupal. It gets even more complex when the new feature are dependent on more than one module. You also have the problem that changing a setting might affect the functionality of already existing features as well.
Yes, there are several modules that lets you export configurations. Views is an example of that. It is very simple to export your views and then import them on the staging or production server. But that is only the views itself, any content types, settings for other modules, taxonomy vocabularies, input filters and so on still have to be taken care of separately.
What about if there was another way of doing this and also get much more control over everything?
Features is the Answer!
The Features module let you do exactly that. It leverages on several other modules, such as Chaos Tool Suite and Strongarm to give you a way of creating a bundle module that contains more or less everything the new feature needs to work.
Simplified it lets you:
- Define what modules are required.
- Define what configurations are needed.
- Generate a module that implements the new feature.
Not only that, since all the required stuff is exported to code, it gives you many other advantages, such as:
- Easily identify if any configuration has been overridden.
- Quickly revert to the default settings for the feature.
- Minimise the time you need to spend on writing the implementation guide.
Creating Lego Bricks
By utilising the power of the Features module you can turn your features into lego bricks. You can build a library of features that then are quite simple to add to a Drupal based website. This will let you reuse a lot of work you already done, by creating standard components (feature exported modules) for common features on websites such as:
- WYSIWYG editing of content (See Karen Stevenson's excellent article WYSIWYG as a Feature for a tutorial)
- Blog Management
- eCommerce
- Gallery
- User Profiles
- Discussion Forum
All of the above examples can be made into Drupal lego bricks using the Features module. Making them quick and easy to deploy on new websites. In many cases you can break things down into several smaller lego bricks for greater flexibility. The eCommerce could have a big base lego brick with all the common configurations and modules needed, then you can have smaller separate lego bricks for adding products, subscriptions, different payment systems and so on.
All this will help you speed up you development and at the same time get much better control over it as well as minimise all the unnecessary work you otherwise have to do if you stick to the traditional way of developing Drupal sites.
Introduction to the Feature Module
The video below is from DrupalCon San Fransico last April. In it Jeff Miccolis, from Development Seed, gives you an excellent overview of it. He starts by giving you some background information as well as giving you more detailed information about what Features will let you do. Then he rounds up giving you a few examples as well.
If you haven't seen it already, I guarantee that the hour it takes for you watch it will be regained multiple times when you start using it in your own projects.
Features Gaining Momentum
The Feature module is gaining momentum within the Drupal community. More and more module maintainers are developing their modules with it in mind. This is great since it will make it even easier to create the Drupal lego bricks I have been talking about.
Personally I am following the development of this module with great interest and I believe it stand a very good chance of becoming the standard Drupal way of exporting configurations.
Are you using it already? If so, please leave a comment with about you experiences with it below.
Oh, and before I forget it - A port to Drupal 7 has started!
- Log in to post comments