Welcome Guest, Not a member yet? Register   Sign In
Configuring Dev & Production environments
#1

[eluser]NateL[/eluser]
Trying something new out today - keeping my dev and production files synchronized. I have my local development environment, and my files auto-uploading via FTP to a test production environment so that I can test locally and on my test production environment nearly at the same time.

Sounds cool - until I realized my MySQL database information is completely different.

I'm wondering now if there is a way, in the CI config, to write an if/else statement that recognizes my dev environment versus my production environment based on what my URL is.

for example:

My Local environment is set up to say samplesite.local

where as when I upload my files to my testing site, my personal site, it's samplesite.nathanledet.com

I'm looking for something like...
Code:
if ($baseurl == 'samplesite.local'){
//use this MySQL info
}
else if ($baseurl == 'samplesite.nathanledet.com' {
// use this MySQL info
}
#2

[eluser]Kamarg[/eluser]
Code:
switch($_SERVER['HTTP_HOST']) {
  case 'samplesite.local':
    //Dev environment
    break;

  case 'samplesite.nathanledet.com':
    // Live site
    break;
}
#3

[eluser]NateL[/eluser]
[quote author="Kamarg" date="1255722669"]
Code:
switch($_SERVER['HTTP_HOST']) {
  case 'samplesite.local':
    //Dev environment
    break;

  case 'samplesite.nathanledet.com':
    // Live site
    break;
}
[/quote]

6 minutes.

You are my hero :-)
#4

[eluser]Clooner[/eluser]
Why not just keep 2 config files. One on the server and the other on the test environment? No extra coding involved!
#5

[eluser]NateL[/eluser]
[quote author="clooner" date="1255723204"]Why not just keep 2 config files. One on the server and the other on the test environment? No extra coding involved![/quote]I thought about that. But the way this sync dealio works on FTP is it looks for files with an updated timestamp and syncs it between the two servers.

In other words - if I modify my config file on my test server, the newer timestamp will be recognized, and that file will be downloaded and overwrite my local dev config file.

Looking now to see if there is a way to ignore, sorta like in SVN.
#6

[eluser]Phil Sturgeon[/eluser]
How to: Support multiple production environments in CodeIgniter
#7

[eluser]NateL[/eluser]
[quote author="Phil Sturgeon" date="1255723710"]How to: Support multiple production environments in CodeIgniter[/quote]

Very nice! bookmarked




Theme © iAndrew 2016 - Forum software by © MyBB