Module Spotlight #2: Environment Indicator

Configuration > System > Backup and Migrate > Restore database..... Did I just load my database export on the live website? oops

If the stress of pressing the wrong button on a live website is familiar to you, you need the Environment Indicator module! On large Drupal projects you will often be using multiple environments. Local development, online development, test, acceptance and finally 'production'. Environments are easily mixed up as they probably look identical in every way except the url in the address bar.

To help you keep sane the environment indicator module will tell you clearly which environment you are currently looking at. Until recently it showed a, frankly rather unpretty, vertical bar adjacent to your page. With a recent update the module got an aesthetic make-over. Now the environment is indicated by coloring the toolbar and adding a label to the toolbar. This is integrated seamlessly with a number of different toolbars, including my favorite: Admin Menu toolbar. I've been testing this version of Environment Indicator for a few weeks now and I really like it. Using a green toolbar on dev, pink on test and red on the production environment I'm always 100% confident about which environment I'm working in. Even after importing a product database into a local development installation...

Regex matching your hostname

If you move content or configuration between your environments by copying over the database, in previous versions this would overwrite your setting environment setting. The latest branch of the module is smarter: it supports Hostname matching to make your site aware of its environment even if after copying around databases:

[[{"fid":"676","view_mode":"default","fields":{"format":"default","field_file_image_alt_text[und][0][value]":false,"field_file_image_title_text[und][0][value]":false},"type":"media","field_deltas":{"1":{"format":"default","field_file_image_alt_text[und][0][value]":false,"field_file_image_title_text[und][0][value]":false}},"attributes":{"class":"media-element file-default","data-delta":"1"}}]]

By entering a regular expression in the Hostname field: .*\.dev.* the module knows that any environment that lives on a .dev hostname should get the green color and "Development" label. I develop on a hostname called, so I get a green label. If I create a new environment at it will automatically get the development indication as well.