(01-09-2015, 09:35 PM)sneakyimp Wrote: I've been exploring the loader and I think I might almost understand things well enough to set up a local PHP config file that overrides the default configuration files (but only if this file is present) but I'm confused by the fact that the various different configuration files define different variables:
config/autoload.php - defines $autoload
config/config.php - defines $config
config/database.php - defines $db
config/hooks.php - defines $hook.php
config/routes.php - defines $route
I also can't figure out how to access the db config values from $this->config->item(). From what I can tell, the db configuration values are not defined in $this->config anywhere.
Can someone suggest a way in which I might use a hook to override the default configuration values. I'm especially interested in overriding db settings, base_url, etc.
I really do NOT want to make changes to .htaccess or the apache config if it can be avoided.
Usually the files define different variables because they are used by different parts of the system. $this->config is not intended to work with any config file which does not use the $config variable. This can be confirmed in Config's load() method, which checks whether $config is set and is an array after including the file, and exits/fails if it does not.
The loader loads the autoload config and expects it to define the $autoload variable. The database library loads the database config and expects it to define the $db variable. The router loads the routes config and expects it to define the $route variable. I think you get the picture.
In most cases, the config files will be loaded from the ENVIRONMENT directory in the config directory if a version of the file is available in that location. There are many different ways to set ENVIRONMENT, so I would recommend just picking a method which works for you, or creating your own method to do this. I wouldn't recommend a hook simply because your hooks can be set per ENVIRONMENT as well, and the only hook that fires before the config class is loaded is the
pre_system hook.