This is a bit hackish but I think it's what you are looking for, so the trick here is to redefine the parse_ini_file
function and make it ignore the invalid passed path ("/usr/local/apache2/myconfigs/settings.ini"
) and use your correct file instead.
This seems straightforward but a bit tricky since your new function should also call the original parse_ini_file
function somehow, that's why you need to rename it first then override it
You will need PHP runkit extension enabled for this, have look at runkit_function_redefine and runkit_function_rename for reference.
Untested but should work, the code should be something around these lines :
runkit_function_rename('parse_ini_file','original_parse_ini_file');
runkit_function_redefine('parse_ini_file', function() {
original_parse_ini_file("C:\wamp64\bin\apache\apache2.4.27\myconfigs\settings.ini", true);
});
Make sure the code above is executed at the start of your application script and any parse_ini_file
call should use your file instead of the hardcoded one.
If there is no single entry point to your application where you can put the code above, you can put it in a separate script and make PHP load before running any script via the auto_prepend_file
setting in your settings.ini
file, also make sure that runkit.internal_override
is set to On
since parse_ini_file
is not a user defined function.