How do you use Variable overrides in drushrc.php?

Events happening in the community are now at Drupal community events on www.drupal.org.
benklocek's picture

How do you use Variable overrides in drushrc.php?

I've got a few ideas from the examples of variables overrides, but I'm curious what uses everyone is using it in dev or production.

I could see using it to set the site title to "DEV" or something, any thing else?

Comments

I'm not sure what variable

greg.1.anderson's picture

I'm not sure what variable overrides are for in drushrc.php. These will not affect your site as viewed through the web server (web browser); for that, set the variable overrides in settings.php.

Chris Charlton's picture

Scenarios where custom drushrc.php file(s) can help with development workflows:

  • Folders on your local development machine are totally different than the live hosting environment, each installation can have their own drushrc.php files so certain paths/options are set differently.
  • Local dev machine can have and use 1 ddrushrc.php file for all local sites.
  • Maybe you like the verbose display of commands, the -v option for Drush, and this can be set as a default inside drushrc.php.
  • Special variables/setup for Multi-site environments, or even multi-multi site setups.
  • Preconfigure where SQL dumps (backups) will be stored when generated by Drush.
  • List additional tables that should not be backed up using the SQL commands in Drush.
  • Sync and Download (dl) configurations like add your SCM credentials.

Chris Charlton, Author & Drupal Community Leader, Enterprise Level Consultant

I teach you how to build Drupal Themes http://tinyurl.com/theme-drupal and provide add-on software at http://xtnd.us

What about site aliases

perusio's picture

Isn't that what site aliases rc files are supposed to do?

All my drushrc files are the same usually.

johnbarclay's picture

I use the

__FILE__

variable to figure out where the site is and call a function to set any drush options that are location specific such as 'r'.

This allows all my drushrc files to look the same on dev and production, unless I'm deviating from my usual conventions.

drushrc.php

require_once('c:/drush/conventions.inc');
$drushrc_file_location =  __FILE__;
$options = drush_options($drushrc_file_location);

I do the same type of switching with my settings.php and name all my dev sites with dev.X.X hostnames so the php knows which db, files path etc to use on dev and production with identical settings.php files.

I have a global $dev variable set in settings.php if the domain starts with dev. that triggers "dev" in the body class and a big "DEV" foreground image in the CSS with high opacity. This helps me avoid confusion more often than others.

Having identical settings.php and drushrc files makes dev and production codebase just a little easier to script back and forth, diff, and do version control.

drush

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: