Features
a better way to package stuff


         Rob Knight
     NWDUG February 2010
About me

‣ Drupal developer since version 4.6
‣ Member of the Drupal Association -
  you should be too!
‣ Working in Manchester at PRWD
Intro
‣ Features is a Drupal module created
  by Development Seed
‣ It enables ‘Features’ to be created
  which package CCK types, Views,
  Contexts and more
‣ It moves configuration from the
  database to code
What is a Feature?

‣ A Feature is a special kind of module
‣ Features consist of generated code
‣ Features are created via the admin UI
‣ Features have version numbers
How a Drupal installation changes

                             Version
     Level      Changes
                             control?
     Core         Rarely       Yes

    Contrib     Regularly      Yes

  Custom code   Frequently    Maybe

   Database     Constantly     No


  Problem: how to manage change
         in the database?
The difference Features make
Example: Packaging
     a blog Feature

‣ ‘Blog Post’ content type
‣ Some views
‣ A Context for displaying blocks
A content type
A simple view
A context
The resulting blog


                 Text




Here we can see the blog content type,
  the context and the view in action
Creating a Feature
Creating a Feature
Creating a Feature
Feature contents
Generated code
Installing the Feature




When the Feature is enabled, all module
  dependencies will be enabled too
Changes




If any component of the feature is changed, the
     Feature is ‘overridden’. In this case, I’ve
                  changed a View
Viewing a ‘diff’




  I can now choose to revert the
changes or update the Feature code
Version control


‣ Because Features are code, they can
  be managed like source code
‣ Updating a Feature is just like
  updating a module
Deployment

‣ Features are great for ‘additive’
  changes
‣ Not so great for ‘destructive’ changes
‣ Complex changes between Feature
  versions are still tricky
Feature Servers

‣ Imagine running your own
  drupal.org-style module repository
‣ Supports “Available Updates”
  monitoring
‣ Powerful integration with drush and
  drush make
What features doesn’t do
         (yet)
‣ Taxonomy
‣ Node content and attachments
‣ Menus


‣ However, alternatives exist and more
  modules are integrating with
  Features
Pitfalls

‣ Many contrib modules as yet
  unsupported
‣ Features isn’t magic - it’s just a
  system for generating code
‣ Upgrades still need some manual
  intervention
Questions and Answers
Thanks for listening

‣ Features is maintained by Development
  Seed and is available at
  http://drupal.org/project/features


‣ My site & blog are at
  http://robknight.org.uk

Features: A better way to package stuff in Drupal