2

I'm currently using the $_SERVER['DOCUMENT_ROOT'] variable inside my config file.

In ExpressionEngine this is returned :

/Applications/MAMP/htdocs/devee

In PHP (no CMS) this is returned :

/Applications/MAMP/htdocs

Is there a place, where ExpressionEngine is changing the $_SERVER['DOCUMENT_ROOT'] ?

Thanks.

6

I would avoid using DOCUMENT_ROOT altogether, to avoid issues between servers. The doc root is specified in your apache config, and depending on your apache setup, isn't always guaranteed to give you the correct path to your root folder.

It's much more reliable to use dirname(__FILE__) (or __DIR__ in PHP 5.3+) for the directory of the current script, and go from there. E.g. (in your config.php file):

$root = realpath(dirname(__FILE__).'/../../../');
$config['theme_folder_path'] = $root.'themes/';
  • Much more flexible than document_root. Thanks you ! – Simon Dec 31 '12 at 10:27
3

I would assume ExpressionEngine is giving you the path to your system folder, since that is were the config.php file is located.

The $_SERVER['DOCUMENT_ROOT'] provides:

The document root directory under which the current script is executing, as defined in the server's configuration file.

It doesn't provide the base path to your html folder; it provides the path to the executing file/script.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.