Welcome Guest, Not a member yet? Register   Sign In
load custom config from root?
#1

[eluser]rossmurphy[/eluser]
is there anyway to load a custom config from somewhere other than the app/config dir?
#2

[eluser]Dam1an[/eluser]
Yes, although if you don't mind me asking, why do you not want it in the config directory?

You can always just include the file like a standard PHP file
Code:
include APPPATH.'my_config.php';

and you can then access the config array like a normal variable.
#3

[eluser]rossmurphy[/eluser]
Ahh great idea.. i would like to keep my config file where it is but i would like custom configs in a different directory for config settings that don't have to do with CI.

Thanks.
#4

[eluser]Dam1an[/eluser]
Another alternative would be to extend the config library, and change the load function to also handle absolute paths
You can then access the config variables like any other config items via the config library
#5

[eluser]rossmurphy[/eluser]
So i tried the include method. I have this in my config file.

Code:
include "./config/config_common.php";

It points to a config dir in the root directory.

In that file i have..

Code:
$config['site_api_url']    = 'bla';
$config['parvor_key'] = 'bla';
$config['site_id'] = 'bla';

But for some reason, the values are no being loaded into the config array.
#6

[eluser]Dam1an[/eluser]
when you say you have the include in your config file, is that refering to application/config/config.php? If so, the relative path is wrong.
In most cases, I tend to avoid relative paths, as it causes problems if/when you move files around relative to each other, so I use APPPATH and BASEPATH




Theme © iAndrew 2016 - Forum software by © MyBB