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

[eluser]dhall[/eluser]
So I know there is the config class and have read the documentation...
but...
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:

database.php
config.php
index.php
.htaccess

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

[eluser]dejan[/eluser]
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') {
include_once('production_overrides.php');
}

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
#3

[eluser]Aken[/eluser]
http://ellislab.com/codeigniter/user-gui...ments.html

http://ellislab.com/codeigniter/user-gui...onfig.html

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