Welcome Guest, Not a member yet? Register   Sign In
Multiple Environment Setup Help

So I know there is the config class and have read the documentation...
I develop on my local and when I go to put it on my server I find myself having to change setting in several different files:


Anyway to setup these files so I don't have to change them when I go back and forth?

Well, there is an obvious way for all PHP files:

if ($_SERVER['SERVER_NAME'] === 'www.production.com') {
$config['param'] = 'value';
} elseif ($_SERVER['SERVER_NAME'] === 'local.development') {
$config['param'] = 'value';

There is also a way to "override" config items, which may be cleaner. Add something like this to index.php:

$assign_to_config['name_of_config_item'] = 'value of config item';

You can obviously keep these in a separate file and do something like:

if ($_SERVER['SERVER_NAME'] === 'www.production.com') {

and keep the $assign_to_config array in that override.

As far as .htaccess goes, it has a condition like:
RewriteCond %{SERVER_NAME} = www.production.com

But I'm personally a lighttpd man, so I don't know all the details Smile



Plenty of info there for setting up environments and their config values. Then, as dejan said, you just need to add some logic somewhere that figures out what environment it's in.

Theme © iAndrew 2016 - Forum software by © MyBB