php.ini error_log directive: finally fixed my code to make it work

phpI always ran into an issue whereby if i set the error_log location for an application/server using ini_set(’error_log’,'PATH’) it wouldn’t log it there. It would log it to whatever path was set in my httpd.conf file, whether it was the global error_log path, or one for a specific virtual host.

I searched high and low on the goog’s, but to no avail, I kept running into php.net bug reports about the behaviour not working. Then, I just tried something I should’ve tried a long time ago, set the write permissions properly (for testing, 777) and gave access to every user on my local machine (eg. on a mac, getinfo on the error log, and make it readable and writable by everyone), and success.

I’ve had a lot of headaches around this that usually ended up with me giving up, but I finally found a fix for my case of it :)

Framework: S^3 (aka S cubed): I’m calling it Smart Setting Selection

558px-Selection.svgIn working on a custom framework (that’s uniting a lot of the best of the existing ones, but keeping it lean and cutting out what I don’t need), I ran into a configuration roadblock which caused me to write some nifty code.

Basically, this framework has a bunch of settings/config files, and some of the files (ini format, using parse_ini_file) are seperated by the following keywords:
local,development,staging,production

Basically meaning, if I have a configuration setting that is supposed to mean something like ‘maxTimeout = 500′, I could, and in a real world application, would have that setting store different values based on which server the code base is being run on (eg. my local would be a lot higher, but the other ones like the production would be much lower for optimization purposes).

This lead me to write some nifty code that will parse all the ini files, and then when I want to retrieve something, it does a check for one of those 4 reserved words. So a real world example would be something like this:

An ini file is parsed and has the following format:

Array
(
[local] => Array
(
[name] => TEST
[cookies] => 1
)
[production] => Array
(
[name] => TEST
[cookies] => 1
)
)

When doing a call to the function and asking for the setting ‘name’, recursively as it moves it’s way down the settings array, it’ll look to see if it contains a keyword of local, production, etc., and if it does, automatically set the value to that array/value. This will be clearer once I OS the framework which won’t be for a while, but to understand it from a code perspective, check this out:


public static function getDetails() {
$details = self::$details;
foreach(func_get_args() as $argument) {
$details = $details[$argument];
if(array_key_exists(Request::getServerRole(),(array) $details))
$details = $details[Request::getServerRole()];
}
return $details;
}

This means that my server will automatically pull the right setting detail based on what server is doing the requesting. I just need to setup my ini files so that if a setting needs to be different based on which server is being loaded, it can be.