<VirtualHost *:80> .... SetEnv APPLICATION_ENV development </VirtualHost>SetEnv sets the APPLICATION_ENV envrionment variable to development for this virtual host. On your production environment you would set this to "production". Next change your config/database.php to something like this:
<?php class DATABASE_CONFIG { var $default = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'DEFAULT_LOGIN', 'password' => 'DEFAULT_PASSWORD', 'database' => 'DEFAULT_DATABASE', ); var $production = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'PRODUCTION_LOGIN', 'password' => 'PRODUCTION_PASSWORD', 'database' => 'PRODUCTION_DATABASE', ); var $development = array( 'driver' => 'mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'DEVELOPMENT_LOGIN', 'password' => 'DEVELOPMENT_PASSWORD', 'database' => 'DEVELOPMENT_DATABASE', ); function __construct() { $env = getenv("APPLICATION_ENV"); if( ($env) && isset($this->{$env})) { $this->default = array_merge($this->default, $this->{$env}); } } } ?>Notice the __construct function. This function merges the default database parameters with the current environment parameters. When I have some time I will also change the core.php config to work like this so you can for example enable debugging on your development environment and disable it on production.
You can follow any responses to this entry through the RSS feed. You can leave a response, or trackback from your own site.