title: PHP file outside doc root needs files outside and inside the document root
body: <p>I have a library of classes, all interrelated.</p>
  
  <p>Some files are inside the document root and some are outside using the <code>&lt;Directory&gt; and Alias</code> features in httpd.conf</p>
  
  <p>Assuming I have 3 files:</p>
  
  <pre><code>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)
  </code></pre>
  
  <p>If alias_directory2.php needs both webroot.php and alias_directory.php, This does not work.
  (Remember alias_directory.php and alias_directory2.php are not in the same locations)</p>
  
  <pre><code>require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php'; //(ok)
  require_once $_SERVER['DOCUMENT_ROOT'].'/alias_directory.php'; //(not ok)
  </code></pre>
  
  <p>This does not work because alias_directory.php is not in the doc root.</p>
  
  <p>Similarly</p>
  
  <pre><code>require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php'; //(ok)
  require_once dirname(__FILE__).'/alias_directory.php'; //(not ok)
  </code></pre>
  
  <p>The problem here is that <code>dirname(__FILE__)</code> will return the path for alias_directory2.php not alias_directory.php.</p>
  
  <p>This works:</p>
  
  <pre><code>require_once $_SERVER['DOCUMENT_ROOT'].'/webroot.php'; //(ok)
  require_once '/full/path/to/directory/alias_directory.php'; //(ok)
  </code></pre>
  
  <p>But is very nasty and is a maintenance nightmare if I decide to move my library to another location.</p>
  
  <p>How do I solve this problem, is seems that I need a way to resolve an Alias folder properly.</p>