Hi everyone
I have a config.ini file that contains the following
[development]
debug = true
database.host = localhost
database.database = dbname
database.username = username
database.password = password
[production]
debug = false
database.host = localhost
database.database = dbLive
database.username = root
database.password = pass
I have used parse_ini to parse the file and I can then retrieve the values of the various settings. However, is there an easy way to tell my application to use the settings in [development] or [production]? I'm sure I did this before but for the life of me I can't figure out what I did.
Many thanks,
Cols2910
Switching from development to production
Moderator: General Moderators
Re: Switching from development to production
Aha. Thats what I have been missing.
Many thanks McInfo
Regards,
Cols2910
Many thanks McInfo
Regards,
Cols2910
Re: Switching from development to production
Hi McInfo (or anyone else who wishes to jump in here)
I have been wracking my brains trying to access the desired variables which I can by doing
$config = parse_ini_file("config/config.ini", true);
if($config['development.debug'])
{
// do sometihing
}
However, I'm still unsure as to how to tell my application to i=use either the development settings or the production settings. I have tried numerous combinations such as
$config[development][debug]
but to no avail. Using 'development.debug' works but how would I tell the application to use the [development]->settings or the [production]->settings?
Many thanks,
Cols2910
I have been wracking my brains trying to access the desired variables which I can by doing
$config = parse_ini_file("config/config.ini", true);
if($config['development.debug'])
{
// do sometihing
}
However, I'm still unsure as to how to tell my application to i=use either the development settings or the production settings. I have tried numerous combinations such as
$config[development][debug]
but to no avail. Using 'development.debug' works but how would I tell the application to use the [development]->settings or the [production]->settings?
Many thanks,
Cols2910
Re: Switching from development to production
Okay I think I finally figured it out
$environment = 'development'; //switch this between production / development
$config = parse_ini_file("config/config.ini", true);
$settings = $config[$environment]['database.username'];
I'm sure there is maybe a better way to do this so if anyone has any suggestions, please feel free to post them here.
Thanks,
Cols2910
$environment = 'development'; //switch this between production / development
$config = parse_ini_file("config/config.ini", true);
$settings = $config[$environment]['database.username'];
I'm sure there is maybe a better way to do this so if anyone has any suggestions, please feel free to post them here.
Thanks,
Cols2910
Re: Switching from development to production
Good idea McInfo. I'll run with that suggestion.
Many thanks,
Cols2910
Many thanks,
Cols2910