On Sat, Sep 12, 2009 at 06:18:50AM +0200, Rico Secada wrote: > Hi. > > Some time ago I developed a small web application that a bunch of users > has installed. > > I have always used the DOCUMENT_ROOT for my includes, but the other day > I installed the application in a subdirectory, and as you've guessed a > lot of the includes didn't work. > > I have been reading up on the subject of absolute vs. relative paths > etc. And on the subject of defining your own document root. > > I need the application to be as user friendly as possible, and I would > like to avoid having users enter path details in the configuration. > > What is the best way to solve this problem? Don't move your files to a subdirectory if they're written to be in the document root (and vice versa). ;-} Seriously. There really isn't a way around this. All your files need to be in the same places at all times relative to each other. You can use absolute paths or relative paths; it doesn't matter. But the files themselves can't be moved. The only alternative to this is to write a search function which searches in fixed locations for files until it finds them. And that's kind of silly. Look at it this way: Major frameworks all specify their subsidiary files to be in certain fixed locations. They'll have directories for javascript files, directories for internal classes, directories for configuration files, etc. They may or may not use relative pathing to refer to those files, but the files themselves must be in a certain location with respect to each other, always. My convention is to set up fixed directories for each type of file (as mentioned above) and then always put files of that type in those directories. Then use relative or fixed pathing as desired from other files that include() those files. If you're using a front controller, then you can use PHP server variables to get the path to that file, and use that as the reference for the location of the other files. (Or maybe I've completely misread what you're trying to do.) Paul -- Paul M. Foster -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php