PHP Going Multiple Directories Back Best Practice
Instead of nesting the dirname calls, according to the documentation for dirname you could call this as of PHP 7:

dirname(__FILE__, 5)


For supporting lower versions of PHP, you could write a parentDirectory function:

function parentDirectory($path, $levels) {
    for ($i = 0; $i &lt; $levels; $i++) {
        $path = dirname($path);
    }
    return $path;
}


Or just embed it inside your current code, without a specific function:

$configPath = __FILE__;
for ($i = 0; $i &lt; 5; $i++) {
    $configPath = dirname($configPath);
}
define('PATH_TO_CONFIG_DIR', $configPath . "/config/");