gkirkup — 2010-06-30T19:35:10-04:00 — #1
On my local site, $SERVER['DOCUMENTROOT'] returns C:/xampp/htdocs. Shouldn't it also add /mysite?
My includes work when I do this:
But won't that cause a problem when I publish my site? I didn't think that /mysite should be in the include.
If this is a problem, how do I fix it?
jake_arkinstall — 2010-06-30T20:41:11-04:00 — #2
This is a common issue, and its solution depends on your application architecture.
Document Root is not the path to your project directory, its the path to the server base directory - i.e. the directory that http://localhost/ maps to.
My typical application works by routing every request to index.php. Therefore I simply use DIR in index.php to get the root.
Would it not make more sense to use a relative path?
dan_grossman — 2010-06-30T20:35:18-04:00 — #3
What's the document root specified in your httpd.conf/httpd-vhosts.conf? That's the document root, it's not an alias for the current directory.
I always have some kind of front controller or dispatcher in my applications, so that's where I define the root using dirname(FILE), so it's relative to the front controller.