Autoload package with database config - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: Autoload package with database config (/showthread.php?tid=54696) |
Autoload package with database config - El Forum - 09-20-2012 [eluser]slapyo[/eluser] I'm using the autoload packages and it's really handy. One thing I'd like to do but can't see to figure out how is to autoload config files with it. Code: $autoload['packages'] = array('/path/to/application'); Inside of /application I have /helpers, /libraries, and /models. Everything works great. I tried to add a /config folder and then put database.php inside of it. I deleted the database.php out of the site's config folder and loaded the site. I get the following error. Quote:The configuration file database.php does not exist. So I looked in /system/database/DB.php and saw this: Code: if ( ! defined('ENVIRONMENT') OR ! file_exists($file_path = APPPATH.'config/'.ENVIRONMENT.'/database.php')) It's looking specifically in the /config or /config/ENVIRONMENT folders. Is there any way to get it to check for a config that is not in that location without editing files in the /system folder? Autoload package with database config - El Forum - 09-20-2012 [eluser]slapyo[/eluser] I've also tried to change the config file in the application to require_once() the path to the config file I want to use. I end up with this error. In application database.php: Code: <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); The other file is the standard database.php file filled out. Quote:No database connection settings were found in the database config file. I know the file is there, I made a test file and included it then dumped the $db variable and it showed everything. Autoload package with database config - El Forum - 09-20-2012 [eluser]slapyo[/eluser] So it works if I just use require() instead of require_once(). I guess because it's already being included by the autoload package, it failed the next time when I used require_once() since it was already included. |