Basically, one of the greatest questions of all time: What are some ways you're using settings.php in your development/staging workflow?
Right now, I have my settings.php file set up like the following, and I base my development on the server's $HOST directive—meaning I can work on dev.example.com for the development (shared) server, local.example.com for my local computer (and other dev's local code checkouts), and www.example.com (or just example.com) for the live site.
(This code is in the 'Database settings' section of settings.php):
$host = $_SERVER['HTTP_HOST'];
$base_url = 'http://'.$host;
$cookie_domain = $host;
switch($host) {
case 'example.com': # Production server
$db_url = 'mysqli://prod_sql_user:[email protected]/prod_db';
$update_free_access = FALSE;
$conf = array (
// Set production config options here...
'example_setting' => 0,
);
break;
case 'dev.example.com': # Development server
$db_url = 'mysqli://dev_sql_user:[email protected]/dev_db';
$update_free_access = FALSE;
$conf = array (
// Set production config options here...
'example_setting' => 0,
);
break;
case 'local.example.com': # Local server
$db_url = 'mysqli://local_sql_user:[email protected]/local_db';
$update_free_access = FALSE;
$conf = array (
// Set production config options here...
'example_setting' => 0,
// Turn off most core caching.
'cache_inc' => 'includes/cache.inc',
'cache' => CACHE_DISABLED,
);
break;
}
?>
This works pretty well for most purposes, but it means we have a lot of extraneous code sitting around in our shared settings.php file... is there a better way?