Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Working with Features module + Drush integration

Working with Features module + Drush integration

November Drupal Singapore Meetup. Topic is Working with Features module + Drush integration. Presented by Ryan Villanueva

Avatar for Ryan Villanueva

Ryan Villanueva

November 28, 2012
Tweet

Other Decks in Technology

Transcript

  1. What is a Features Module? • Contributed Module that allows

    us to export parts of a Drupal site’s configuration (which is typically stored in the database) into code. • Takes the site’s components and bundling it together into an exportable "feature” module. Wednesday, 28 November, 12
  2. What is a “feature” module • exportable Package generated by

    the Features module. • is like any other Drupal module except that it declares its components (e.g. views, contexts, CCK fields, etc.) in its `.info` file. Wednesday, 28 November, 12
  3. • you can add custom code (e.g. custom hook implementations,

    other functionality, etc.) to its `*.module` as you would with any other module. • Features will keep your changes to *.module and any other files you add Wednesday, 28 November, 12
  4. Exportable components • Content types • Fields • Menus •

    Taxonomies • Image styles • System variables (Strongarm) • User roles and permission • Views • Panels • Context • Any module can support exporting in Feature • etc.... Wednesday, 28 November, 12
  5. Using Drush with Features • features-diff (fd) Show the difference

    between the default and overridden state of a feature. • features-export (fe) Export a feature from your site into a module. • features-list (fl) List all the available features for your site. • features-revert (fr) Revert a feature module on your site. • features-revert-all (fr-all, fra) Revert all enabled feature module on your site. • features-update (fu) Update a feature module on your site. • features-update-all (fu-all, fua) Update all feature modules on your site. Wednesday, 28 November, 12
  6. Reverting Features using Drush Code: drush features-revert will remove the

    overrides. Overrides: drush features-update will update the exported feature with the displayed overrides Component: views_view /* Display: Master */ $handler = $view->new_display('default', 'Master', 'default'); < $handler->display->display_options['title'] = 'Slideshow'; --- > $handler->display->display_options['title'] = 'VIews Slideshow'; $handler->display->display_options['use_more_always'] = FALSE; $handler->display->display_options['access']['type'] = 'perm'; Wednesday, 28 November, 12
  7. Keep RED Code (Code Database) Keep GREEN Database (Database Code)

    $ drush fr demo_slideshow Do you really want to revert views_view? (y/n): y Reverted views_view. $ drush fu demo_slideshow Module appears to already exist in sites/demo/modules/features/demo_slideshow Do you really want to continue? (y/n): y Created module: demo_slideshow in sites/demo/modules/features/demo_slideshow Wednesday, 28 November, 12
  8. • Easier deployment • Allows version control (track changes, revert,

    etc) • Separates Site configuration from Site content. • Easily distribute configurations to customers and developing sites – and reuse existing ones. • Use it as starting point for your own module. • Integrates with Drush Why Features? Wednesday, 28 November, 12