drupal presentation for capitalcamp 2011: features driven development

35
Features Everywhere! Feature Driven Development By Jay Callicott Mediacurrent Consultant CapitalCamp 2011 July 22, 2011

Upload: mediacurrent

Post on 10-May-2015

1.901 views

Category:

Technology


0 download

DESCRIPTION

Mediacurrent's Jay Callicott reviews and analyzes how to leverage Features within Drupal at CapitalCamp 2011 in Washington D.C.

TRANSCRIPT

Page 1: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Features Everywhere!

Feature Driven Development

By Jay CallicottMediacurrent ConsultantCapitalCamp 2011July 22, 2011

Page 2: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Features Everywhere! Outline

• Part I - The Basicso About Featureso About Jayo The Problemo The Solutiono How to Create a Basic Feature

• Part 2 - Diving Deepero Context & Featureso Panels & Featureso Adding stuff that isn't exportableo Feature Driven Developmento Real World Examples!

Page 3: Drupal Presentation for CapitalCamp 2011: Features Driven Development

About Features

• 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• Who Uses Features?

o Originally created by DevelopmentSeedUsed extensively in OpenAtrium

o Phase2Used extensively in OpenPublishNow maintained by Phase2

Page 4: Drupal Presentation for CapitalCamp 2011: Features Driven Development

About FeaturesOpenAtrium

Page 5: Drupal Presentation for CapitalCamp 2011: Features Driven Development

About Features

Page 6: Drupal Presentation for CapitalCamp 2011: Features Driven Development

About Jay

• Mediacurrent Web Developer• Developed Drupal sites since version 4.6• Why Features?

o Started using features in early 2010o Developed features extensively on a large OpenPublish-

based multi-site installation, working with Phase2o Now use features on every site big and small

• OpenChurch distribution maintainero Features used extensively

Page 7: Drupal Presentation for CapitalCamp 2011: Features Driven Development

The Problem

• Drupal has many items in the databaseo Viewso CCK Content typeso Imagecacheo Contexto Panelso Settingso Permissions

• Moving these between environments is cumbersome• Backing these up is a pain• No version control• Developers can accidentally override each other's work

Page 8: Drupal Presentation for CapitalCamp 2011: Features Driven Development

The Solution - Features!

• Features' Benefits:o Work more in the „problem space‟o Encapsulation - Yes!o Backup - Yes!o Version Control - Yes!o Easier deploymento Code reuse!o A place for your form_alters and nodeapi() hookso 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)

Page 9: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a Feature

• Install and Enable the Following:o Featureso Strongarm (important) Saves additional settings with your content types that

would otherwise not get saveo ContextRecommended over admin/build/block

o Diff (recommended, only on non-production environments)Can view differences in code

Page 10: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a Feature

Go to /admin/build/features

(Sample screen)

Page 11: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a FeatureGo to /admin/build/features/create and add components

Page 12: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a Feature

Click download and save tar file to hard drive (this contains feature module files)

Page 13: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a FeatureExtract your feature folder to your project (screenshot showing 7zip on Windows 7)

Page 14: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a Feature

Add/commit to svn/git, svn up and enable on your Drupal site

Page 15: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a Feature

Your views, content types, etc will now be enabled, you have just deployed a feature!

Page 16: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to Create a Feature

To update use drush features-update + svn commit to update your features or 'recreate' for additions (new views, etc)

Page 17: Drupal Presentation for CapitalCamp 2011: Features Driven Development

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

Page 18: Drupal Presentation for CapitalCamp 2011: Features Driven Development

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....

Page 19: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Context Example Screenshot

Page 20: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Adding Context to a Feature

Page 21: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Panels & Features

• Panels export to features easilyoFalls under 'Panels' or 'Page Manager' in

dropdown in components• I like panels for node layouts!

o (overriding page manager node template)

Screenshots next....

Page 22: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Panels Feature Example

context placed blocks

panel regions & views

Page 23: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Panels Feature Underneath...

Page 24: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Panel Feature Underneath

Using CCK, views, panel, strongarm

Page 25: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Adding a Panel to a Feature

under "Panels" or "Page Manager"

Page 26: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to export non-exportables

• Features doesn't export everything, but it's still a module!

• Next: simple example, creating a vocabulary with a featureo (Note: features_extra does this for you)

Page 27: Drupal Presentation for CapitalCamp 2011: Features Driven Development

How to export non-exportables

• Anything you can do in a module you can do in a feature

Using hook_install() & hook_uninstall()

Page 28: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Feature Driven Development

• My methodology (adapted from OpenAtrium, DevSeed, OpenPublish)o Create a feature for every content typeo Package with any related viewso Package panels and node template overrides!o Package relevant imagecache presetso Sometimes directly related permissionso Sometimes package related contextso Place all related form_alters, nodeapi hooks,

hook_menus(), etc in the .module file• That's it!

Page 29: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Real World Examples!

• Seeing is believing, some (more) real world screenshots of feature lists

Page 30: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Real World List Screenshots

Page 31: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Real World List Screenshots

Page 32: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Real World List Screenshots

Page 33: Drupal Presentation for CapitalCamp 2011: Features Driven Development

Real World Screenshots

The trend is I always have at least 1 feature for each content type

Page 34: Drupal Presentation for CapitalCamp 2011: Features Driven Development

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?

Page 35: Drupal Presentation for CapitalCamp 2011: Features Driven Development

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 Makeo http://chicago2011.drupal.org/sessions/zero-

distribution-using-features-profiler-and-drush-make

Hit me up on twitter: http://twitter.com/drupalninja/

Questions??