tags:

views:

41

answers:

2

Hi, I have multiple sub-domains within the document_root. And multiple folders/classes within those sub-domain folders. I need something that will help me with my include_once paths, but $_SERVER[DOCUMENT_ROOT] goes too far down. And if I were to use this, and transfer the website folder later, all my include_once paths will/might break.

Hope my question is clear... Any recommendations?

Essentially, what I'm trying to do is, access classes, that are located in different folders, from different files. When it works for some files, it'll break in others, because of the way I'm writing the include statements.

Ie. class test{include_once '../Data/employee.php';} A file that will include the class test, will work. But say another file, from a different directory, includes the class test. It'll break. Because the other file can be 3 folders deep, instead of just one.

A: 

This could solve your problem:

$relpath = "";
$tempvarrelpathdir = explode("/",dirname($SERVER['PHPSELF']));
for($i=count($tempvarrelpathdir); $i>0; $i--) if($tempvar_relpathdir[$i] != '') $relpath .= "../";

It will get the relative path to root dir...

Zuul
Still no reason for this answer to have a vote down...
Zuul
+1  A: 

You can set include path per sub-domain (inside the <virtualhost>) using Apache's php_value directive.

vartec
I'm worried about the client moving servers. If they move server, they'll need to reconfigure the new apache server using your solution. Is there a way without apache configurations?
Idealflip
you can have that in .htaccess files in the directories themselves.
vartec
I did not do exactly this, but I assume it's correct, since relocating the folder to the real document root did what I wanted. So essentially, if I told Apache to use a different document root, in theory this answer should work.
Idealflip