Features Everywhere!
Feature Driven Development
By Jay Callicott, Mediacurrent
Features Everywhere! Outline
About FeaturesThe ProblemThe SolutionHow to Create a FeatureFeature Driven Development
About Features
Who Uses Features?Created by DevelopmentSeed
Used extensively in OpenAtriumPhase2
Used extensively in OpenPublish
Recommended ReadingManaging and deploying configuration with exportables and the Features module - DrupalCon presentation by Jeff Miccolis of Development SeedMaking and Using Features in Drupal - Blog by Young Hahn of Development Seed
The Problem
Drupal has many items in the databaseViewsCCK Content typesImagecacheContextSettings
Moving these between environments is cumbersomeBacking these up is a painNo version controlDevelopers can accidentally override each other's work
The Solution - Features!Features' Benefits:
Work more in the ‘problem space’Encapsulation - Yes!Backup - Yes!Version Control - Yes!Easier deploymentCode reuse!A place for your form_alters and nodeapi() hooksDrush integration
And much, much more!Replace install profiles!
Features break an install into componentsCreate a distribution with drush .make
(music site, newspaper site, govt, blog, etc)
How To Create a Feature
Install and Enable the Following:FeaturesStrongarm (important)
Saves additional settings with your content types that would otherwise not get save
ContextRecommended over admin/build/block
Diff (recommended)Can view differences in code
How to Create a FeatureGo to /admin/build/features
(Sample screen)
How To Create a FeatureGo to /admin/build/features/create and add components
How to Create a FeatureClick download and save tar file to hard drive (this contains feature module files)
How to Create a FeatureExtract your feature folder to your project (screenshot showing 7zip on Windows 7)
How to Create a Feature
Add/commit to svn/git, svn up and enable on your Drupal site
How to Create a FeatureYour views, content types, etc will now be enabled, you have just deployed a feature!
How to Create a FeatureTo update use drush features-update + svn commit to update your features or 'recreate' for additions (new views, etc)
How to Create a FeatureRevert components if you a) updated a feature on another environment or b) want to restore a feature to it's original state
How to Create a FeatureAdd all your hooks to your .module file, e.g. form_alter(), nodeapi hooks, etc.
Feature Driven DevelopmentKill the customcontent module
Doesn't mean anythingIsn't modular
Create a 'Feature' for every feature on your Drupal siteMy methodology adapted from OpenAtrium, DevSeed, OpenPublish
Create a feature for every content typePackage with any related viewsPackage relevant imagecache presetsSometimes directly related permissionsI package all context in it's own feature, but some package related context in each featurePlace all related form_alters, nodeapi hooks, hook_menus(), etc in the .module file
That's it!
The End
More Links/Resources:Features Project PageDevelopmentSeed Blog for updated information on FeaturesAutomating Drupal deployment with Drush and Features - Drupalcamp Austin Presentation by Adam Jensen and Adrian Rollett | UNT.edu