Mysql DB settings when deploying

My config file has root / root as the passwords because that’s what’s required by MAMP. Obviously these aren’t the same settings when I need to deploy to my production server. I could change it manually when deploying, but this seems like a bad / inconvenient way of doing it. Any ideas on how to solve this issue?

Basically I need to set different mysql users/passwords between my local server and my production server.

Thanks!

Something like this, maybe:


$hostname = $_SERVER['SERVER_NAME'];


switch ( strtolower($hostname))

{

case 'localhost':

case '127.0.0.1':

	$db_config = '/db_local.php';

	break;

default:

	$db_config = '/db.php';

	break;

}


...


'db' => require(__DIR__ . $db_config),


...

Where would this code be put?

In your config, of course.

Wherever you configure the ‘db’ component.

Thanks a lot Joe! I got confused for a sec there but yeah this should definitely work.