I have a class library, all interconnected.
Some files are inside the root of the document, and some are outside using functions <Directory> and Aliasin httpd.conf
Assuming I have 3 files:
webroot.php (Inside the document root)
alias_directory.php (Inside a folder outside the doc root)
alias_directory2.php (Inside a **different** folder outside the doc root)
If alias_directory2.php is needed both webroot.php and alias_directory.php, this does not work. (Remember that alias_directory.php and alias_directory2.php are not in the same place)
require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php';
require_once $_SERVER['DOCUMENT_ROOT'].'/alias_directory.php';
This does not work because alias_directory.php is not in the root of the doc.
Similarly
require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php';
require_once dirname(__FILE__).'/alias_directory.php';
The problem is that it dirname(__FILE__)will return the path for alias_directory2.php and not alias_directory.php.
It works:
require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php';
require_once '/full/path/to/directory/alias_directory.php';
But this is very unpleasant and is a nightmare for maintenance if I decided to move my library to another location.
, , Alias.