Hi all,
I'm creating a custom install for SS where my team enters both dev and live database settings during installation.
Works fine, and I planned to use the set_dev_servers method to handle the logic between the credentials.
Here is my code:
Director::set_dev_servers(array(
'localhost',
'127.0.0.1',
'114.111.111.111',
'114.111.111.112', // Both of these IP's are our Dev server
));
// Database credentials. Logic here for switching between servers.
// As Dev mode is automatically set by IP address only, we can just check if we are in Dev Mode and switch.
global $databaseConfig;
if(Director::isLive()) {
// Site is in LIVE MODE
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "liveserver",
"username" => "liveuser",
"password" => "livepassword",
"database" => "livedatabase",
);
} else {
// Site is in DEV MODE
$databaseConfig = array(
"type" => "MySQLDatabase",
"server" => "localhost",
"username" => "devuser",
"password" => "devpassword",
"database" => "devdatabase",
);
}
However, when I view a new installation on the dev server with the above in _config.php, Director::isLive() validates to true and it uses the wrong credentials.
Anyone see what I'm doing wrong there, or what may be going on?
Aaron