Drupal7, Features and Tracking Changes

Graphical development in a CMS like Drupal7 is wonderful. It is possible to develop complex sites with very little coding. It is great for getting started and for small sites. The anxiety begins to take over when the site starts getting larger. And the set of developers is not just you alone.

As the complexity of site increases, you need to separate the development environment from the production environment. You may want to have a separate testing environment as well. For development, you need minimal representative data. For testing, you may need simulated data in order to test for scalability and performance. The last thing you as a developer want is to be remembered for messing up live content; and the safest way to do that is to stay away from the operational site!

Since the data about the site and the content are in the same database, you may want to selectively backup and restore parts of database. However, it is usually simpler to do the development; and when everything is working well, repeat the steps on the test and the deployment sites.

If the steps are being repeated, how do you ensure that no mouse click or field entry is different in the live site from the development site. Furthermore, when multiple developers are involved, at some point or other, you will need to know “who did what and when”.

How do you keep track of features being added to your site? It would be much simpler if the changes you make in Drupal7 using the graphical interface could be saved as a text file, which could be used to implement the same changes in the test and deployment servers. Furthermore, you could implement source code control using a repository like git or subversion. This is what you may do with UML modelling tools like argouml or forms design tools like glade.

Since this need is hardly unique, it is inevitable that some people must have implemented a solution and, indeed, they have. The features module(http://drupal.org/project/features) is one such solution.

Features Module

It is very easy to overlook this module. The name is very inappropriate for Google search! Plus, it seems to add nothing to the development. The usage statistics are, however, impressive. Over 75,000 sites have installed it and the number continues to grow with Drupal 7. You will find the current statistics at http://drupal.org/project/usage.

I agree with the comment in http://codekarate.com/blog/top-ten-best-drupal-7-contrib-modules:

If you aim to become a serious Drupal developer, you can't live without the feature module.

You may think of a feature as a use case. You want to group all changes you made to a Drupal site which implements some user need. But what does that mean?

Your new requirement may need to add new vocabulary in the taxonomy module. The next step would be that you may require additional content types, which may use the additional vocabulary you have defined. Finally, these content need to be viewed. You may need to define custom views. You may need to define menu links, permissions etc.

You have completed the needed functionality and are ready to define a new feature. You give it suitable name and edit components to add to this feature. It is remarkably simple. You will need to add the strongarm module in order to export the vocabulary.

When all the components have been added to the feature, you export it as tar file which can then be deployed on any other system. You may want to go through a tutorial to understand the steps – e.g. http://www.ostraining.com/blog/drupal/features/.

If you make changes to any of the components or you add components to your feature, you can re-export the revised feature and deploy the updated version on the other systems.

The content of the tar file can be added to a repository like git and you have your version control for the feature.

If every capability of your site is part of some feature, your entire site is managed by version control. The code for the site is now in the repository and distinct from the content.

You can choose to apply (or ignore) the advice and methodologies of software engineering to development of a Drupal7 projects as well; but you won't be able to say that it can't be done!