Welcome Guest, Not a member yet? Register   Sign In
Loading database and config from outside the system directory
#1

[eluser]Russ Back[/eluser]
Might sound like an odd one this, but here goes...

I have a site that will be replicated across domains and servers so I want to keep my system directory free of site-specific config items (views and everything else are identical on all installations).

But my problem is I have to store site-specific settings in an /system/application/config/whatever.php file and database settings in /system/application/config/database.php when what I really need to do is load these from outside, something like /ci_config.php.

Anybody done this before or got any ideas?
#2

[eluser]rogierb[/eluser]
The easiest way is to place you application folder outside the system folder.

The other way is to *hack* index.php and make a constant (eg. NEW_CI_CONFIG) to the place you want to store your config file(s) and edit the database.php and config.php so they reference(include) the new NEW_CI_CONFIG/ci_config.php
#3

[eluser]Russ Back[/eluser]
Thanks for the reply. I'd prefer not to hack away at the codebase as I want to maintain the ability to upgrade if possible (OK so I can track changes with SVN but it's a lot easier if I don't have to).

What changes would be required to move the application dir outside of system?
#4

[eluser]rogierb[/eluser]
Just edit the $application_folder path in index.php. And move the application folder;-)
#5

[eluser]Russ Back[/eluser]
Sorry, figured that out once I'd posted :-)

Have got around it now by extending the load() method of the CI_Config class so that it will load from the root if it receives a specific path request.

Thanks for your help again.
#6

[eluser]Eric Barnes[/eluser]
I did it by just deleting everything out of the db config file and adding:
Code:
<?php
include('full/path/to/db.php');

Then in the new db.php file copy and paste the original array.
#7

[eluser]n0xie[/eluser]
Just use symlinks?
#8

[eluser]vanquish[/eluser]
Anyone have a code example that shows the use of symlinks for this purpose?




Theme © iAndrew 2016 - Forum software by © MyBB