0
votes

We are using Drupal 6 for a number of our web sites. We are moving them all into Git for version control. Each site will have a dev server, a test server and a live server. I'm wondering about best practices for handling the settings.php file since the database connection info will obviously differ between the servers. I've seen solutions ranging from switch statements to an include file. The include file solution stated here http://drupaldork.com/2011/11/local-settings-development-sites seems to be a good solution, but I'm wondering what you end up leaving in the ACTUAL settings.php file. In other words if each server has a "local" settings file like settings.local.php which contains the connection info for that particular server, do you remove the connection info from the real root settings.php? Or do you leave it? If you leave it, what do you put there? Does it matter because it just ends up getting overridden by the local settings file anyway? Should the connection info in the main root settings.php be some kind of default connection info?

2

2 Answers

3
votes

One of the way, i would prefer is not to keep settings.php in Git. https://help.github.com/articles/ignoring-files

In our case, we keep codebase under Git but settings.php files are ignored. So that Prod, Sandbox & local environment will have their own settings.php files.

0
votes

We keep 2 settings.php file includes in the repo but not the base settings.php.

My settings.php file for production is as normal. Just databsae settings and default stuff. For development my settings.php file has the database settings and an include to a file that is stored in the repo called settings.dev.php.

# Additional site configuration settings.
if (file_exists('/Users/User/Sites/site.com/sites/default/settings.dev.php')) {
  include_once('/Users/User/Sites/site.com/sites/default/settings.dev.php');
}

Settings.dev.php includes switches to turn off caching and set environment indicator:

// Secure Pages
$conf['securepages_enable'] = FALSE;

// Environment Indicator
$conf['environment_indicator_color'] = 'blue';
$conf['environment_indicator_enabled'] = TRUE;
$conf['environment_indicator_text'] = 'Development Server';

// Robots disable
$conf['robotstxt'] = 'User-agent: *
Disallow: /';

// Turn off Caching and such
$conf['cache'] = FALSE;
$conf['page_compression'] = FALSE;
$conf['preprocess_css'] = FALSE;
$conf['css_gzip'] = FALSE;
$conf['preprocess_js'] = FALSE;
$conf['javascript_aggregator_gzip'] = FALSE;

Settings.php is ignored in the repo but the settings.dev.php is included. We also keep a settings.stage.php in the repo. Setting values in settings.php file for prod needs to be done very carefully as it can interfere with some modules and prevents you from being able to quickly change settings if needed. But you can do the same thing with a settings.prod.php.