Welcome Guest, Not a member yet? Register   Sign In
Move database and config files
#1

[eluser]Eric Barnes[/eluser]
Hi,

I am wanting to move the config/database.php and config/config.php out of the config directory and into the root of a site.

I had the idea to create a new file named settings.php and include everything from these two files in it but that doesn't seem to work.

I wanted to ask if anyone had any ideas on how to move these files out with out editing the core?
#2

[eluser]jedd[/eluser]
I think libraries - core or user - look for a config file of the same name as themselves.

If that is the case, then you'd have to do some serious hackage to make the database class, for instance, look into a different location for a different filename.

Can I ask what the intent / benefit is of fiddilng around with this stuff?
#3

[eluser]Eric Barnes[/eluser]
[quote author="jedd" date="1238641373"]Can I ask what the intent / benefit is of fiddilng around with this stuff?[/quote]

My intent was to build a web form installer that would write to this file with the db connection settings. (Like when installing WordPress). That way it would be easier to explain and they would just have to chmod my special folder or file. Basically prevent novices from going way into the file system where they have no business.
#4

[eluser]Daniel Moore[/eluser]
Place your settings file where you were wanting to like you stated, and have it put the variables in there you were wanting to configure.

Then, in the config.php and database.php files, simply place a "require_once(/path/to/settings.php)" statement at the top so that those values will be imported.

There is no need to mess with the core. Just use a "require_once" or "include_once" and you should be good to go.
#5

[eluser]Eric Barnes[/eluser]
Thanks Daniel,

I actually tried that and couldn't get it working. But when I went to reply with what I was trying it magically starting working. Sad I always hate that.

But great advice and thanks for that.
#6

[eluser]Thorpe Obazee[/eluser]
just requiring files and autoloading would be enough. I did it when my employer needed everything in one 'settings' file.

edit: just noticed that you have 68 posts, your project is 68kb and your avatar is kind '68' too :p
#7

[eluser]Eric Barnes[/eluser]
lol What can I say. I guess 68 is my lucky number. Wink




Theme © iAndrew 2016 - Forum software by © MyBB