2. Features Everywhere! Outline
About Features
The Problem
The Solution
How to Create a Feature
Feature Driven Development
3. About Features
Who Uses Features?
Created by DevelopmentSeed
Used extensively in OpenAtrium
Phase2
Used extensively in OpenPublish
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
4. The Problem
Drupal has many items in the database
Views
CCK Content types
Imagecache
Context
Settings
Moving these between environments is cumbersome
Backing these up is a pain
No version control
Developers can accidentally override each other's work
5. The Solution - Features!
Features' Benefits:
Work more in the ‘problem space’
Encapsulation - Yes!
Backup - Yes!
Version Control - Yes!
Easier deployment
Code reuse!
A place for your form_alters and nodeapi() hooks
Drush integration
And much, much more!
Replace install profiles!
Features break an install into components
Create a distribution with drush .make
(music site, newspaper site, govt, blog, etc)
6. How To Create a Feature
Install and Enable the Following:
Features
Strongarm (important)
Saves additional settings with your content types that
would otherwise not get save
Context
Recommended over admin/build/block
Diff (recommended)
Can view differences in code
7. How to Create a Feature
Go to /admin/build/features
(Sample screen)
8. How To Create a Feature
Go to /admin/build/features/create and add components
9. How to Create a Feature
Click download and save tar file to hard drive (this contains
feature module files)
10. How to Create a Feature
Extract your feature folder to your project (screenshot showing
7zip on Windows 7)
11. How to Create a Feature
Add/commit to svn/git, svn up and enable on your Drupal site
12. How to Create a Feature
Your views, content types, etc will now be enabled, you have
just deployed a feature!
13. How to Create a Feature
To update use drush features-update + svn commit to update
your features or 'recreate' for additions (new views, etc)
14. 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
15. How to Create a Feature
Add all your hooks to your .module file, e.g. form_alter(),
nodeapi hooks, etc.
16. Feature Driven Development
Kill the customcontent module
Doesn't mean anything
Isn't modular
Create a 'Feature' for every feature on your Drupal site
My methodology adapted from OpenAtrium, DevSeed,
OpenPublish
Create a feature for every content type
Package with any related views
Package relevant imagecache presets
Sometimes directly related permissions
I package all context in it's own feature, but some
package related context in each feature
Place all related form_alters, nodeapi hooks,
hook_menus(), etc in the .module file
That's it!
17. The End
More Links/Resources:
Features Project Page
DevelopmentSeed Blog for updated information on
Features
Automating Drupal deployment with Drush and Features -
Drupalcamp Austin Presentation by Adam Jensen and
Adrian Rollett | UNT.edu