metho:
I guess I should clarify what I mean by 'complicated'. I agree that it's a good way to go, for sure, but for my liking it could be a bit more 'automatic'. In fact, I used to do the same thing that you do, but found that I was forgetting to change the 'super flag' too many times and then getting weird errors.
Nowadays I do one of two things:
1) just make sure that I never copy over the config file... I have a habit of 'packaging' anything I'm about to upload, anyway, so I spot the rogue config file pretty quickly.
2) have various config files, all named according to the server name.
Just to expand on (2) there. In your example, instead of 'local', 'test' and 'live' , I would have three config files: 'localhost.config.php', '123.45.67.89.config.php' and 'www.siteDomain.com.config.php'. Then when the file is accessed I would grab the server name, prepend it to 'config.php' and then go from there. Basically the same concept as yours, but a little more automatic: I don't need to change any variables, which I like
In the case of 'www.siteDomain.com.config.php' I might also have a 'siteDomain.com.config.php' file, just in case, that would simply include 'www.siteDomain.com.config.php'.
Having said all that, 95% of my work these days is CMS plugins, so it's not that much of an issue for me anyway.
Again, I would just like to reiterate that there are problems with including via relative paths: normally it won't be an issue but let me tell you.... when you hit it, it sucks.
Instead of rewriting it, let me just copy and paste what I said at
http://forum.joomla.org/index.php/to...html#msg278278 (I'm Narcissus over there, for what it's worth).
Quote:
As an example, imagine this really poorly drawn directory structure:
DIR_A: fileA
: fileB
: DIR_A_B: fileAB
: fileB
: DIR_A_B_C: fileABC
If fileAB includes '../fileB' and fileABC includes '../fileAB' then fileABC will actually end up including fileB from the DIR_A_B directory, even though the included fileAB references the fileB in DIR_A.
This is because the include effectively copies the code directly in to the file. Once it's there, the include of '../fileB' references the subdirectory DIR_A_B.
Hence, including files with relative paths is a bad idea, as then you can't just include files all across the code base.
|
It may seem like an unusual situation but if you had a config.php file in your root for your web app and then another config.php file in a subdirectory for a plugin (for example) then things may get hairy.
As far as I'm concerned it's a bizarre issue as in theory, I would have thought that the dirname( __FILE__ ) solution would suffer the same fate. It doesn't and I don't know why... I daresay the issue will be fixed eventually, but until then, that's why I do the dirname thing (which I'm glad to hear worked).
BTW: I don't want you to think I'm disagreeing with you. Your approach is definitely a good one (and a lot better than many of the PHP hacks on this forum... all present company excluded

), but I just thought I'd share what I've done in an effort to not have to worry about forgetting to change things.