My PHP application has different config files with their different settings and their different paths. But all of them need to access to just one database connection file. I would like to avoid mention its path separately on them with many ../
and ../../
. How can I write a same code and use it in all of them?
Imagine that my PHP application has this hierarchy for its config files:
root
root/config/db.php (This file is what I want to mention from all config files.)
root/admin/config/conf.php
root/users/conf.php
Actually what I need is something that detect the root path of my project and create a same directory path generally.