Issue
I have usually put database and website-specific configuration values into global variables within a .php file. This gets included into any page that needs to access the database.
Is there anywhere more sensible that these things should go? Can I add arbitrary values to php.ini, and if so how? Or how about http.conf in apache? Can I configure my website that way?
Ideally, I'd like a solution that means the config isn't being read on every single request.
Solution
I found out a better way through fiddling around. You can add arbitrary config options to php.ini, e.g.
[MyGreatWebsite]
dbname=db_awesome
And you can retrieve them with the get_cfg_var
function, e.g.
get_cfg_var('dbname')
It's not exposing things through phpinfo (As an env variable would) and it's only reading the config once (Verifiable because changing the values requires a server restart)
Answered By - izb
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.