[development] How implement global variables that vary depending on the server (i.e. production, test, demo) within Drupal?

Dylan Wilder-Tack dylan at io.com
Thu Mar 17 22:07:35 UTC 2011


I create a second config file, local_settings.php. Then I configure it to override anything in the main settings file by adding this to settings.php:

if (file_exists('./'. conf_path() .'/local_settings.php')) {
  include_once './'. conf_path() .'/local_settings.php';
}
settings.php is placed in version control, and local_settings.php is not. Upon deployment, the local settings file is then symlinked to a shared directory in each server.  In my case the symlink is created by the :after_update_code task in capistrano, but you could manage this local config file any way you want.

If the cap stuff sounds interesting, there's code on my blog: http://metaltoad.com/132


On Mar 17, 2011, at 10:40 AM, John Mitchell wrote:

> For java webapps within Apache Tomcat I use a web.xml file which contains the global variables that are specific to that server so that the production server will have one web.xml file and the test server will have a different web.xml file.
> 
> How can I do something similar for global variables that vary depending on the server (i.e. production, test, demo) within Drupal?
> 
> Thanks,
> 
> John



More information about the development mailing list