From: Robert P. J. Day

> On Tue, 16 Mar 2010, John Black wrote:
>> On 03/16/2010 06:57 PM, Robert P. J. Day wrote:
>> >    i have a project (let's call it "proj") which lives in the
>> > directory and which contains several subdirs, some of which might
>> > contain their own subdirs and so on.  some of those subdirs might
>> > contain utility classes that i want to include or require
>> > so i want to be able to just:
>> >    require 'util.php';
>> > and have the PHP include path "do the right thing."  right now,
>> > ugly, as in, having PHP files that do:
>> >    require '../../proj/util.php';
>> > meaning every single file that wants to include another
>> > file has to know its relative position in the proj hierarchy.
>> I used to use auto detecting absolute paths but switched to relative
>> paths when a client decided to switch his hosting company, I *think*
>> it was GoDaddy. They required relative paths when using the shared
>> SSL server or the browser would throw errors.
>> It is really not bad as long a you keep your directory structure
>> consistent. I have never received a bug report because of an include
>> path issue. It also does not matter where the root directory of the
>> app is located since everything is relative anyway. There is also no
>> need for the user to configure anything because of the relative
>> paths.
>> So I just set $include = './include/abc/def/' at the top of the
>> executing php page and use it further down. You make $include a
>> global or simply pass $include to functions or classes when they
>> need to include files. I use the later approach.
>> As I said I never had a problem with it, it just requires
>> consistency.
>  i'm not entirely sure what you're suggesting here, but i don't think
> it will work for me as one of the things i want to do is set up a
> "test" directory, inside which i might have subdirectories with more
> test routines, so i can't guarantee *anyone's* position relative to
> the top of the "proj" directory.
>  i might even want to write PHP scripts and place them quite some
> distance from the "proj" directory but still want to include utility
> scripts from the "proj" directory.  based on how i've done this with
> shell and makefile-based projects in the past, the easiest solution
> seemed to be to simply demand that users set a single environment
> variable identifying the location of the "proj" directory, and base
> everything off of that by extending the include path.  at that point,
> everything falls into place and all include/require references work
> relative to the top of the "proj" tree.
>  i think that's the direction i'm going to go, unless someone has a
> compelling reason not to.  thanks.

IOW, you want to point into the first project's test directory from
other projects when you can't know the relative paths between those

I suspect you will have to manage that on a machine by machine basis,
unless you can convince the entire development team to create a common
directory structure that encompasses all projects.

Bob McConnell

PHP General Mailing List (
To unsubscribe, visit:

Reply via email to