Setting various environments (development, production) based on the URL

I am trying to setup environments in Drupal based on the URL. For example, if I go to mysite.local, it will use localdb and it will change the name of the site to "Local Mysite"; if I go to mysite.com, it will switch automatically to use productiondb and set the name to "Mysite".

This is a similar setup I use for most MVC based frameworks:

define('DEVELOPMENT', 'mysite.local');
define('PRODUCTION', 'mysite.com');

switch ($_SERVER['SERVER_NAME']) {
  case DEVELOPMENT:
    // development server
    $config['base_url']    = "http://mysite.local";
    $config['title']    = "DEVELOPMENT Mysite";
    $config['debug']    = 1;
    break;

  default:
    // live server
    $config['base_url']    = "http://mysite.com/";
    $config['title']    = "Mysite";
    $config['debug']    = 0;
    break;
}

Is there something like that in Drupal7 already (I don't want to use different sites, only different settings for the same site), and is there some sort of convention where this switch needs to happen (I am currently thinking about settings.php).

6
задан kiamlaluno 16 April 2011 в 17:06
поделиться