I have to deal with complex directories hierarchy, and I am facing the common trouble of include path with PHP.I have searched the web but I haven't found anything that fit my needs.For instance, I was using a simple directory hierarchy that never fail: no php script in the site root, only one level of subdirectory, all php script in this sublevel. To include a php file, I was simply using relative path, always starting with '../' just like in this example:\[code\]include( '../my_subdirectory/my_script.php' ) ;\[/code\]This way, I can be sure to locate the file I want... But there is some drawback:
- I can't have more than one level of subdirectory (reason: when a file include a file that include another file, the path used to include the third file is not relative to the path of second file file, but relative to the path of the very first file).
- Coming from a C++ background (using handmade makefile), I have always thought it was a dirty way to do it
- centralized in only one file
- portable from a server to another without any change (if possible)
- keep php's include simple and elegant, no complex string concat, this should work this way: "include('directory_a/directory_b/my_php_script.php')"