Welcome Guest, Not a member yet? Register   Sign In
Autoload package with database config
#1

[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'))
  {
   if ( ! file_exists($file_path = APPPATH.'config/database.php'))
   {
    show_error('The configuration file database.php does not exist.');
   }
  }

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?
#2

[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');
require_once('/path/to/application/config/database.php');

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.
#3

[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.




Theme © iAndrew 2016 - Forum software by © MyBB