Skip to content

Instantly share code, notes, and snippets.

@skwashd
Created October 4, 2013 03:12
Show Gist options
  • Save skwashd/6820419 to your computer and use it in GitHub Desktop.
Save skwashd/6820419 to your computer and use it in GitHub Desktop.
It is very useful to have different Drupal configurations in different environments. The easiest way to do this is via setting values in the $conf array in settings.php. For my site builds I generally create a sites/default/config directory that contains the per environment settings. When working with Acquia Cloud and Pantheon the db credentials…
<?php
/**
* Example settings.php which supports per environment configs on different hosting platforms.
*/
$include = '';
// Pantheon
if (isset($_SERVER['PANTHEON_ENVIRONMENT'])) {
$include = __DIR__ . "/config/settings.{$_SERVER['PANTHEON_ENVIRONMENT']}.php";
}
// Acquia
elseif (isset($_ENV['AH_SITE_ENVIRONMENT'])) {
$include = __DIR__ . "/config/settings.{$_ENV['AH_SITE_ENVIRONMENT']}.php";
}
// Local dev
else {
// local extends dev but is excluded from the repo via .gitignore
$include = __DIR__ . '/config/settings.local.php';
}
// Check the file exists as it might not have been created yet.
if (file_exists($include)) {
require_once $include;
}
@agold2
Copy link

agold2 commented Oct 4, 2013

Thanks for sharing. Would you mind also sharing some examples of what kind of settings you are changing per environment?

@skwashd
Copy link
Author

skwashd commented Oct 7, 2013

@agold2 error_level, site_name and environment_indicator_text are 3 right off the top of my head. DB credentials are another.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment