Streamlining your Development

With Drush, Features, and Install Profiles

One thing every good shop will have is a generic install profile that allows them to quickly deploy a base install that has all the common features they include in all their sites.  On Drupal, this is done with install profiles, drush, and features.

Drush

Drush is a command line shell and scripting environment for drupal.  It gives you a lot of commands you can run from the command line of your server to interact with your drupal install.  This is particularly useful during a site setup, since usually that is done via a script or shell environment.  The majority of drush commands can be found on their website, along with useful resources and FAQs.  There are any number of uses for drush:

  • Using coder to check that your code meets the coding standards
  • Backing up and syncing sites
  • Migrating content from other sites
  • Exporting content from your site
  • And much more

The primary commands we'll be using for our install script are:

  • make-generate and make: Export the current modules into a make file, and install a make file
  • site-install: run the site install script
  • zen: create a subtheme of zen
  • pm-enable: enable modules or themes
  • pm-disable: disable modules or themes
  • variable-set: set a drupal variable
  • cache-clear: clear the drupal cache

Features

Features is a module that allows you to export configurations and dependencies into packages that can be installed on other sites or maintained through version control.  This means if you build a blog or ecommerce site you can export the re-usable features of that blog or ecommerce into a feature that you can re-use on your next blog or ecommerce site.  It also works with a variety of other modules to let you set drupal variables or define default blocks.  It saves these into a normal drupal module that then you can add your own custom code or libraries to, making it a nice way to package up parts of your site into files that then can be managed and pushed via version control.

Installation Profiles

An installation profile (sometimes called a distribution) is a built in part of drupal that allows you to package up a set of modules and settings into a reusable feature.  This sounds a lot like the features module, but there's a big difference:

  • Features must be maintained in that feature after being built, it can be overriden but it should be put back into the feature when it's ready to go live.  Dependencies must remain on until altered in the feature module.
  • Install profiles are used once during install and then can be overriden on that site however you want.  It is meant for your base site install, not an individual part of your site.

One way to think of it is that features are modules that implement a specific feature of your website, where install profiles are templates for your whole website.  Install profiles can make use of drush make files, so when installed from drush they install the entire makefile automatically.  Here are the components of a common install profile:

  • .info file: Describes the install profile and lists modules to enable on it's install.
  • .profile file: Form alters and default functions for your profile.
  • .install file: Hooks for your install process, where you define a lot of settings and do the majority of your changes.
  • .make files: Base, core, and contributed module make files, these allow you to define what to install, where to get it from, where to put it, and what patches to install.

Putting it all together

There are a variety of ways to deploy your site: chef, puppet, scripts, etc.  The primary steps of this are to:

  1. Setup your directories, database, and webserver.
  2. Download drupal and your install profile with drush make.
  3. Setup your drupal site with drush site-install, including setting your admin account, choosing your install profile, etc.
  4. Setup a custom theme with drush zen.
  5. Run any follow up commands you want (such as file permissions, etc)
  6. Enable any features you have built that should be present on this site.