When I use the following code:
print_r($_SERVER);
?>
I get a nice list off all server variables. However, when I enter the same code i
It's best not to rely on this variable as it isn't always set (just as you discovered).
Try setting and using a constant like this instead:
define('PUBLIC_PATH', '/var/www/path/to/public');
// OR something like:
define('PUBLIC_PATH', dirname(__DIR__) . '/public');
Now use PUBLIC_PATH instead of $_SERVER['DOCUMENT_ROOT']