I’m developing from my Windows laptop but need to test my development on my shared Linux hosting. I have thrown together the following in place of the normal $application_path = "application"; line.
$env['laptop']['ip'] = '127.0.0.1'; $env['laptop']['host'] = 'MATT-WINDOWS7'; $env['laptop']['path'] = 'private';$env['mattpotts']['ip'] = '12.34.56.78'; $env['mattpotts']['host'] = 'my.webhost.com'; $env['mattpotts']['path'] = '../private/blah';
$ip = $_SERVER['SERVER_ADDR'];
$host = php_uname('n');
foreach($env as $e)
if($e['ip'] == $ip && $e['host'] == $host)
$application_folder = $e['path'];
unset($env);
if(!isset($application_folder))
die('application folder not set');
…which works fine for setting the application path but now I’m running into trouble with the need for a database config for each environment.
I can make it work with a few simple ifs but I was wondering if there’s a best practice solution to this one.
Cheers
Use revision control such as Subversion. Have one configuration file deployed to your test environment and a modified version checked out in your development environment. Simply tell your client to not commit those configuration changes so they don’t make it to your testing/production environment.
This is definitely the best practice solution 🙂
P.S. If you don’t feel like setting up a Subversion server, there’s always hosted solutions like Beanstalk and if you’re on Windows, TortoiseSVN is a slick client.