Welcome Guest, Not a member yet? Register   Sign In
Multiple Code Igniter Config Folders
#6

[eluser]adamfairholm[/eluser]
I've solved it!

Randy - that's funny about the error logging - it's confusing, because where the config file would be loaded (Common.php), there isn't any error logging as far as I can see.

I figured out which one of the three APPPATH variables it was dealing with, and I put in copies of the config files where CI apparently was looking for them so I could do some debugging. I found that libraries/Config.php being loaded in the Codeigniter.php file was only loading my custom config files (as specified through autoload.php).

The difference is I want a whole config FOLDER rather than a separate config FILE which I think was tripping up my logic. Turns out as I looked through CI, each config file is loaded in a separate place (not in libaries/Config.php as I had thought before I really carefully read through codeigniter/Codeigniter.php).

So, for anyone who might be doing the same thing, here is what you need to change to create an entirely new config FOLDER. This may be somewhere else, but I couldn't find it.

Step 1: Modifying index.php

In the bootstrap index.php file for a site, after the application folder variable, add a variable for the server path to your special config variable folder.

Code:
$application_folder = "/**server_path**/application";

$config_folder = "/**server_path**/application/config/this_site";

It doesn't have to be in the application folder.

Then, after defining BASEPATH, add your own global variable and define it as your server path from the $config_folder variable:

Code:
define('CFP', $config_folder.'/');


Step 2: Replacing APPPATH in key places

By default Code Igniter uses the APPATH global variable to load different config files. All you need to do is find these APPATH instances and replace them with CFP. Keep in mind that you may need to modify the hard-coded part of the path too.

For example, this:

Code:
include(APPATH.'config/'.$file.EXT);

Becomes:

Code:
include(CFP.$file.EXT);

Here are the locations of these instances (with the exceptions of mimes and smileys which I couldn't find).

codeigniter/Codeignter.php - line 52 (constants)
codeigniter/Common.php - lines 145 & 150 (main config)
libraries/Config.php - lines 69 & 78 (custom config files)
libraries/Loader.php - line 890 (autoload)
database/DB.php - line 30 (database)
libraries/Hooks - line 69 (hooks)
libraries/Router - line 82 (routes)
libraries/User_agent - line 87 (user_agent)

I'll post it when I find the smileys and mimes, but until then, this has worked for me.

WARNING: I have not tested this very vigorously. If I run into any disasters with this method, I'll post that as well.


Messages In This Thread
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 07:37 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 08:26 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 08:42 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 08:57 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 09:10 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 10:29 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 10:42 PM
Multiple Code Igniter Config Folders - by El Forum - 07-28-2008, 11:06 PM
Multiple Code Igniter Config Folders - by El Forum - 12-14-2010, 08:39 PM
Multiple Code Igniter Config Folders - by El Forum - 12-14-2010, 09:03 PM
Multiple Code Igniter Config Folders - by El Forum - 12-14-2010, 09:23 PM
Multiple Code Igniter Config Folders - by El Forum - 01-24-2011, 05:47 PM



Theme © iAndrew 2016 - Forum software by © MyBB