This document provides an overview of feature driven development in Drupal. It discusses how features allow encapsulation of items like views, content types, and configurations to make deployment and version control easier. It provides instructions for creating basic features and exporting non-exportable items. Feature driven development is presented as creating a feature module for each content type along with related components. Examples of real world feature lists are shown to demonstrate how features are used to package common site elements.
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Drupal Presentation for CapitalCamp 2011: Features Driven Development
1. Features Everywhere!
Feature Driven Development
By Jay Callicott
Mediacurrent Consultant
CapitalCamp 2011
July 22, 2011
2. Features Everywhere! Outline
• Part I - The Basics
o About Features
o About Jay
o The Problem
o The Solution
o How to Create a Basic Feature
• Part 2 - Diving Deeper
o Context & Features
o Panels & Features
o Adding stuff that isn't exportable
o Feature Driven Development
o Real World Examples!
3. About Features
• Recommended Reading
Managing and deploying configuration with exportables
and the Features module - DrupalCon presentation by
Jeff Miccolis of Development Seed
Making and Using Features in Drupal - Blog by Young
Hahn of Development Seed
• Who Uses Features?
o Originally created by DevelopmentSeed
Used extensively in OpenAtrium
o Phase2
Used extensively in OpenPublish
Now maintained by Phase2
6. About Jay
• Mediacurrent Web Developer
• Developed Drupal sites since version 4.6
• Why Features?
o Started using features in early 2010
o Developed features extensively on a large OpenPublish-
based multi-site installation, working with Phase2
o Now use features on every site big and small
• OpenChurch distribution maintainer
o Features used extensively
7. The Problem
• Drupal has many items in the database
o Views
o CCK Content types
o Imagecache
o Context
o Panels
o Settings
o Permissions
• Moving these between environments is cumbersome
• Backing these up is a pain
• No version control
• Developers can accidentally override each other's work
8. The Solution - Features!
• Features' Benefits:
o Work more in the „problem space‟
o Encapsulation - Yes!
o Backup - Yes!
o Version Control - Yes!
o Easier deployment
o Code reuse!
o A place for your form_alters and nodeapi() hooks
o Drush integration
• And much, much more!
o Replace (or supplement) install profiles!
Features break an install into components
o Create a distribution with drush .make
(music site, newspaper site, govt, blog, etc)
9. How to Create a Feature
• Install and Enable the Following:
o Features
o Strongarm (important)
Saves additional settings with your content types that
would otherwise not get save
o Context
Recommended over admin/build/block
o Diff (recommended, only on non-production
environments)
Can view differences in code
10. How to Create a Feature
Go to /admin/build/features
(Sample screen)
11. How to Create a Feature
Go to /admin/build/features/create and add components
12. How to Create a Feature
Click download and save tar file to hard drive (this contains
feature module files)
13. How to Create a Feature
Extract your feature folder to your project (screenshot showing
7zip on Windows 7)
14. How to Create a Feature
Add/commit to svn/git, svn up and enable on your Drupal site
15. How to Create a Feature
Your views, content types, etc will now be enabled, you have
just deployed a feature!
16. How to Create a Feature
To update use drush features-update + svn commit to update
your features or 'recreate' for additions (new views, etc)
17. How to Create a Feature
Revert components if you a) updated a feature on another
environment or b) want to restore a feature to it's original state
18. Context & Features
• http://drupal.org/project/context
• Context is used primarily for block
placement (admin/build/block replacement)
• Exports to features out of the box
Screenshots next....
21. Panels & Features
• Panels export to features easily
o Falls under 'Panels' or 'Page Manager' in
dropdown in components
• I like panels for node layouts!
o (overriding page manager node template)
Screenshots next....
25. Adding a Panel to a Feature
under "Panels" or "Page Manager"
26. How to export non-exportables
• Features doesn't export everything, but it's
still a module!
• Next: simple example, creating a
vocabulary with a feature
o (Note: features_extra does this for you)
27. How to export non-exportables
Using hook_install() &
hook_uninstall()
• Anything you can do in a module you can do in a feature
28. Feature Driven Development
• My methodology (adapted from OpenAtrium,
DevSeed, OpenPublish)
o Create a feature for every content type
o Package with any related views
o Package panels and node template overrides!
o Package relevant imagecache presets
o Sometimes directly related permissions
o Sometimes package related contexts
o Place all related form_alters, nodeapi hooks,
hook_menus(), etc in the .module file
• That's it!
29. Real World Examples!
• Seeing is believing, some (more) real world
screenshots of feature lists
34. Wait! A couple last items to cover
• Features Extra
• Drush Make
• Distributions with .make
• Features Server
• Share Features!
• Drupal “Apps”(introduced by Ph2)
• What about Drupal 7?
• I'm a beginner – is this for me?
35. The End
Resources
• Features Project Page
o http://drupal.org/project/features
• Features Extra Project Page
o http://drupal.org/project/features_extra
Related
• From Zero to Distribution using Features, Profiler, and
Drush Make
o http://chicago2011.drupal.org/sessions/zero-
distribution-using-features-profiler-and-drush-make
Hit me up on twitter: http://twitter.com/drupalninja/
Questions??