Welcome Guest, Not a member yet? Register   Sign In
switching between development production server
#1

[eluser]a&w[/eluser]
Looking for suggestion on how people handle switching between development and production server.

I thought there might be some switches for changing the base_url, system_folder, application_folder, etc.

I didn't want to reinvent the wheel if someone of the more learned folks around here had some tried and true methods/suggestions.

Basically thinking I could have the same file to use on my development server and simply upload them to the production server (shared host) to have them automagically work.
#2

[eluser]Scriptor[/eluser]
Right now I have the base_url on my production config set to the production value, otherwise I try to not make any changes to the config.php file. Also, make sure you have at least two different database configurations, one for development and one for production. In the production site activate the relevant database configuration (info on how to do this is in the database.php file in the config folder).

For now I simply try to remember what changes I've made to what files, and upload the necessary files to the server. However, I am (slowly) working on a library that would automate deployment. I'd like to see if there's anything made by the community though.
#3

[eluser]Rick Jolly[/eluser]
I define a boolean constant in index.php:
Code:
define('IS_PRODUCTION', ($_SERVER['SERVER_NAME'] != 'localhost'));
Then I use that constant to conditionally set:
- application and system directories
- base_url
- database

The only thing I have to change between production and localhost environments is the RewriteBase in the .htaccess file.
#4

[eluser]a&w[/eluser]
[quote author="Rick Jolly" date="1215209302"]I define a boolean constant in index.php:
Code:
define('IS_PRODUCTION', ($_SERVER['SERVER_NAME'] != 'localhost'));
Then I use that constant to conditionally set:
- application and system directories
- base_url
- database

The only thing I have to change between production and localhost environments is the RewriteBase in the .htaccess file.[/quote]
I originally was checking $_SERVER['HTTP_HOST'] for 'local' or '192.168' in application/config and then set $config['environment'] = 'development' or 'production'. I then checked that config item when setting the database $active_group. I guess one more to alter might be the error_reporting.

I tried your way and like it better.

I had also gone ahead an used a separate .htaccess file, I'm not too good with .htaccess and couldn't figure out if I could dynamically switch the configs in there.

Thanks to both of you.
#5

[eluser]Unknown[/eluser]
Would doing the following be a concise and satisfactory solution, or am I missing the inherent system suicide that such an approach would create.

$config['base_url']= "http://".$_SERVER['SERVER_NAME'];


Would something along the lines of this be better...

switch ( $_SERVER['SERVER_NAME'] ) {
case 'staging.server.name':
$config['base_url']= "http://www.staging-server.com";
break;
case 'testing.server.name':
$config['base_url']= "http://www.testing-server.com";
break;
case 'localhost':
$config['base_url']= "http://localhost/";
break;
default:
$config['base_url']= "http://www.staging-server.com";
break;
}




Theme © iAndrew 2016 - Forum software by © MyBB