About Me

Arpit Rastogi

Drupal Developer @Srijan Goa

@arpit_rastogi10

Agenda

  • Problem with configuration management till Drupal 7.
  • Features as Solution.
  • Features as deployment tool.
  • Features as site building tool.
  • Features Architecture.
  • Do's and Don'ts while building features.

Drupal Architecture

Content

Configuration

Code Base

Web Server

Data Base

Problem - Deployment

Content

Configuration

Code Base

Web Server

Content

Configuration

Code Base

Web Server

@Development

@Production

Problem - Reuse of configuration

Site A

Site B

Site C

Site D

Common site components

Problem - Collaboration

We found the solution

To the Rescue

Features Module.

 

What it does?

  • Pulls configuration into code base.
  • Allows tracking of configuration changes.
  • Allows re-use, sharing of configuration.
  • Bundles up components as module.
  • Allows easy switching to earlier configuration stage when used with version control.

Content

Configuration

Code Base

Web Server

Data Base

Demo: Basics of Features

States of Feature

  • Default - When code base and database are in sync, no action required.
  • Overridden - When either of code base or database is updated, revert/update are the possible actions to reach to default state.
  • Needs Review - This is effectively the same state as overridden, but generally means there are more complicated changes and it's recommended you review the differences prior to reverting the feature.

Actions on Feature State

  • Revert - Update database to revert to configurations which the feature module contains. Be careful!, it will wipe off all the un-tracked configurations which are done from UI and not present in feature.
  • Recreate/Update - Update code base to get the latest manual database changes into feature code base.

@Development 

@Staging

Step 1: Manual Configurations

Create(Action)

feature v 7.x-1.0 Default(State)

Push to stg

Install feature 7.x-1.0

Default(State)

Features States and Action

@Development 

@Staging

Step 2: Modify Configurations 

Re-Create(Action)

feature v 7.x-1.1 Default(State)

Push to stg

feature 7.x-1.1

Overridden(State)

feature v 7.x-1.0 Overridden(State)

Revert(Action)

feature v 7.x-1.1 Default(State)

Demo : Features update workflow

Features as site building tool

  •  Features satisfying a specific use case and are independent can be helpful in building platform for multi-site.
  •  Features allows to port configurations from prototypes to build a consolidated site, help in discovery phase of project.
  •  The more we can break functionalities to have them independent the better we can build features on them.

Protyotype:1

Protyotype:2

Protyotype:3

Create Feature

Create Feature

Consolidated Site with approved functionalities

Feature Architecture

  • More of a working agreement with in the team, proper plan to be laid out.
  • Ask what if I disable this feature, will it impact the site or will it simply turn off the use case offer by feature.
  • Feature what you configure, keep it simple.
  • A second thought before building the feature.

Feature Toolbox

  • Features Module
  • Diff Module - Allows to see difference in code base and data base in terms of configuration.
  • Strongarm Module - Allows site variable to get into features.
  • Drush - Command line feature integration
  • Features Extra Module - Allows you to export blocks, nodequeues.
  • Feature Override Module - Allows  to create separate features for overriden configurations to keep default features intact.

Do's and Don'ts for feature building

  • Do not only test the feature from where it is built from.
  • Keep updating features and keep them in default state.
  • Should not create one giant feature, break your features each satisfying a use-case.
  • See it more than just a tool for configuration migration, instead see them as site building block.
  • Try to keep your features independent to each other.
  • Take database back before any major/doubtful feature update as features may cause loosing of configuration.
  • An overridden feature is not ready to deploy.
  • Divide base field and instance fields in separate features.
  • Do not feature components that admin is supposed to change frequently. 

Features in Drupal 8

  • Features will still need to exist in D8
  • (Configuration Management Initiative) Use CMI API as much as possible.
  •  Still need to be able bundle configurations and deploy it to a site
  •  Will coordinate with CMI

Features with Drush

  • Drush commands for features.

features-add (fa)

Add a component to a feature module.

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)

  features-revert (fr)
  Revert a feature module on your site.
  features-revert-all
  Revert all enabled feature module on your site. (fr-all, fra)

  features-update (fu)
  Update a feature module on your site.

  features-update-all
  Update all feature modules on your site. (fu-all, fua)

Thank You

#DCH Features

By Arpit Rastogi

#DCH Features

DCM Features module as site building tool

  • 2,011