[eluser]xoRiZ[/eluser]
I generally use a development / production switch for my URL, Database, and system_path.
First thing I'm doing in v2.0.1:
/index.php - Replaced the switch that was there; with this.
Code:
if (trim(`hostname`) == 'machine_host')
{
define('ENVIRONMENT', 'development');
}
else
{
define('ENVIRONMENT', 'production');
}
switch (ENVIRONMENT)
{
case 'development':
error_reporting(E_ALL);
$system_path = '/var/www/development/framework/v2.0.1';
$application_folder = '../application';
break;
case 'production':
error_reporting(0);
$system_path = '/var/www/framework/v2.0.1';
$application_folder = '../application';
break;
default:
exit('The application environment is not set correctly.');
}
/application/config/database.php - Set the database settings based on what environment we're in.
Code:
$active_group = 'default';
$active_record = TRUE;
$db['default']['hostname'] = 'localhost';
$db['default']['username'] = '';
$db['default']['password'] = '';
$db['default']['database'] = '';
$db['default']['dbdriver'] = 'mysql';
$db['default']['dbprefix'] = '';
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = '';
$db['default']['char_set'] = 'utf8';
$db['default']['dbcollat'] = 'utf8_general_ci';
$db['default']['swap_pre'] = '';
$db['default']['autoinit'] = TRUE;
$db['default']['stricton'] = FALSE;
replace with:
Code:
$active_group = ENVIRONMENT;
$active_record = TRUE;
$db['development']['hostname'] = 'localhost';
$db['development']['username'] = '';
$db['development']['password'] = '';
$db['development']['database'] = '';
$db['development']['dbdriver'] = 'mysql';
$db['development']['dbprefix'] = '';
$db['development']['pconnect'] = TRUE;
$db['development']['db_debug'] = TRUE;
$db['development']['cache_on'] = FALSE;
$db['development']['cachedir'] = '';
$db['development']['char_set'] = 'utf8';
$db['development']['dbcollat'] = 'utf8_general_ci';
$db['development']['swap_pre'] = '';
$db['development']['autoinit'] = TRUE;
$db['development']['stricton'] = FALSE;
$db['production']['hostname'] = 'localhost';
$db['production']['username'] = '';
$db['production']['password'] = '';
$db['production']['database'] = '';
$db['production']['dbdriver'] = 'mysql';
$db['production']['dbprefix'] = '';
$db['production']['pconnect'] = TRUE;
$db['production']['db_debug'] = TRUE;
$db['production']['cache_on'] = FALSE;
$db['production']['cachedir'] = '';
$db['production']['char_set'] = 'utf8';
$db['production']['dbcollat'] = 'utf8_general_ci';
$db['production']['swap_pre'] = '';
$db['production']['autoinit'] = TRUE;
$db['production']['stricton'] = FALSE;
I will also set the /application/config/config.php base_url variable based on the environment.
Edit:
The structure I also use is generally more like this (incase anyone is wondering / interested)
/var/www/framework (System / user guide directories)
/var/www/applications/domain.com/application (Contains my full application folder)
/var/www/applications/domain.com/htdocs (Contains my index.php, htaccess and assets folder)
Edit2:
Added /v2.0.1 to framework structure (which is actually what I've converted to using /framework/v####)
Great update guys.
Thanks,
Nick