Configuring Environment Indicators
Learn how to implement an environment indicator for Drupal and WordPress sites running on Pantheon.
This section provides information on how to install an indicator to receive alerts when changes are made in your site and environments.
We recommend installing the Pantheon HUD plugin on WordPress sites and the Environment Indicator module on Drupal sites.
This doc uses Terminus example commands with common variable names for the site and environment names. Before you begin these steps, set the variables $site
and $env
in your terminal session to match your site name and the Dev (or Multidev) environment:
export site=yoursitename
export env=dev #or Multidev name
WordPress: Pantheon HUD
The Pantheon HUD plugin is developed and maintained on GitHub. Create an issue with questions, feature requests, or bug reports.
Set the connection mode to SFTP for the Dev or Multidev environment via the Pantheon Dashboard or with Terminus:
terminus connection:set $site.$env sftp
Install and activate Pantheon HUD from within the Dev or Multidev environment's WordPress Dashboard (
/wp-admin/plugin-install.php?tab=search&s=pantheon+hud
) or with Terminus:terminus wp $site.$env -- plugin install pantheon-hud --activate
Deploy the plugin to the Test environment within the Site Dashboard or with Terminus, and clear the site cache:
terminus env:deploy $site.test --sync-content --updatedb --note="Install Pantheon HUD plugin" terminus env:clear-cache <site>.test
If you're working from a Multidev environment, merge to Dev first.
Activate the plugin within the WordPress Dashboard on the Test environment (
/wp-admin/plugins.php
) or with Terminus:terminus wp $site.test -- plugin activate pantheon-hud
Deploy the plugin to the Live environment within the Site Dashboard or with Terminus, and clear the site cache:
terminus env:deploy $site.live --note="Install Pantheon HUD plugin" terminus env:clear-cache <site>.live
Activate the plugin within the WordPress Dashboard on the Live environment (
/wp-admin/plugins.php
) or with Terminus:terminus wp $site.live -- plugin activate pantheon-hud
All environments will now show the following indicator for users who are logged in with the manage_options
capability:
You can restrict this to specific users with the pantheon_hud_current_user_can_view
filter:
add_filter( 'pantheon_hud_current_user_can_view', function(){
$current_user = wp_get_current_user();
if ( $current_user && in_array( $current_user->user_login, array( 'myuserlogin' ) ) ) {
return true;
}
return false;
});
Drupal: Environment Indicator
The Environment Indicator module is officially supported for Drupal sites.
Set the connection mode to SFTP for the Dev or Multidev environment via the Pantheon Dashboard or with Terminus:
terminus connection:set $site.$env sftp
Install and enable the Environment Indicator module using the Drupal interface or with Terminus:
terminus drush $site.$env -- en environment_indicator -y
Add the following within settings.php
for your version of Drupal:
Drupal 8/9/10+
/*
* Environment Indicator module settings.
* see: https://docs.pantheon.io/guides/environment-configuration/environment-indicator
*/
if (!defined('PANTHEON_ENVIRONMENT')) {
$config['environment_indicator.indicator']['name'] = 'Local';
$config['environment_indicator.indicator']['bg_color'] = '#505050';
$config['environment_indicator.indicator']['fg_color'] = '#ffffff';
}
// Pantheon Env Specific Configig
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
switch ($_ENV['PANTHEON_ENVIRONMENT']) {
case 'lando': // Localdev or Lando environments
$config['environment_indicator.indicator']['name'] = 'Local Dev';
$config['environment_indicator.indicator']['bg_color'] = '#990055';
$config['environment_indicator.indicator']['fg_color'] = '#ffffff';
break;
case 'dev':
$config['environment_indicator.indicator']['name'] = 'Dev';
$config['environment_indicator.indicator']['bg_color'] = '#307b24';
$config['environment_indicator.indicator']['fg_color'] = '#ffffff';
break;
case 'test':
$config['environment_indicator.indicator']['name'] = 'Test';
$config['environment_indicator.indicator']['bg_color'] = '#b85c00';
$config['environment_indicator.indicator']['fg_color'] = '#ffffff';
break;
case 'live':
$config['environment_indicator.indicator']['name'] = 'Live!';
$config['environment_indicator.indicator']['bg_color'] = '#e7131a';
$config['environment_indicator.indicator']['fg_color'] = '#ffffff';
break;
default:
//Multidev catchall
$config['environment_indicator.indicator']['name'] = 'Multidev';
$config['environment_indicator.indicator']['bg_color'] = '#e7131a';
$config['environment_indicator.indicator']['fg_color'] = '#000000';
break;
}
}
Drupal 7
/*
* Environment Indicator module settings.
* see: https://docs.pantheon.io/guides/environment-configuration/environment-indicator
*/
$conf['environment_indicator_overwrite'] = TRUE;
$conf['environment_indicator_overwritten_position'] = 'top';
$conf['environment_indicator_overwritten_fixed'] = FALSE;
if (!defined('PANTHEON_ENVIRONMENT')) {
$conf['environment_indicator_overwritten_name'] = 'Local';
$conf['environment_indicator_overwritten_color'] = '#505050';
$conf['environment_indicator_overwritten_text_color'] = '#ffffff';
}
// Pantheon Env Specific Config
if (isset($_ENV['PANTHEON_ENVIRONMENT'])) {
switch ($_ENV['PANTHEON_ENVIRONMENT']) {
case 'lando': // Localdev or Lando environments
$conf['environment_indicator_overwritten_name'] = 'Local Dev';
$conf['environment_indicator_overwritten_color'] = '#990055';
$conf['environment_indicator_overwritten_text_color'] = '#ffffff';
break;
case 'dev':
$conf['environment_indicator_overwritten_name'] = 'Dev';
$conf['environment_indicator_overwritten_color'] = '#307b24';
$conf['environment_indicator_overwritten_text_color'] = '#ffffff';
break;
case 'test':
$conf['environment_indicator_overwritten_name'] = 'Test';
$conf['environment_indicator_overwritten_color'] = '#b85c00';
$conf['environment_indicator_overwritten_text_color'] = '#ffffff';
break;
case 'live':
$conf['environment_indicator_overwritten_name'] = 'Live!';
$conf['environment_indicator_overwritten_color'] = '#e7131a';
$conf['environment_indicator_overwritten_text_color'] = '#ffffff';
break;
default:
//Multidev catchall
$conf['environment_indicator_overwritten_name'] = 'Multidev';
$conf['environment_indicator_overwritten_color'] = '#e7131a';
$conf['environment_indicator_overwritten_text_color'] = '#000000';
break;
}
}
Deploy the module to the Test environment within the Site Dashboard or with Terminus, and clear the site cache:
terminus env:deploy $site.test --sync-content --updatedb --note="Install and configure Environment Indicator"
terminus env:clear-cache <site>.test
If you're working from a Multidev environment, merge to Dev first. Remember that the module will need to be activated again for each new environment.
Deploy the module to the Live environment within the Site Dashboard or with Terminus, and clear the site cache:
terminus env:deploy $site.live --updatedb --note="Install and configure Environment Indicator"
terminus env:clear-cache <site>.live
All environments will now show a color-coded environment indicator, as defined within the above settings.php
snippet.