title: PHP relative path: can I configure it?
body: <p><strong>tl;dr:</strong> How do I make PHP interpret relative paths in include/require statement from the perspective of the current file?</p>
  
  <p>This is yet another question about that old issue in PHP about relative paths. Please bear with me, as I couldn't find any solution for what I am specifically trying to do.</p>
  
  <p>Consider the following directory tree and files:</p>
  
  <pre><code>[www]:
      index.php
      config.php
      [webroot]:
          home.php
  </code></pre>
  
  <p><code>index.php</code> requires <code>home.php</code>, found inside <code>webroot</code>:</p>
  
  <pre><code>require('webroot/home.php');
  </code></pre>
  
  <p><code>home.php</code> requires <code>config.php</code>, found in the parent directory:</p>
  
  <pre><code>require('../config.php');
  </code></pre>
  
  <p>My problem is that this won't work in my local development environment (Ubuntu 14.04 LTS / 15.10), whereas it runs flawlessly in production. Every mentioned environment is running Apache 2 and PHP 5.<br>
  Strangely, this does run locally when I run it inside my Vagrant VM (Ubuntu 12.04 LTS), accessing it from the host machine. But, right now, I cannot run a VM here.</p>
  
  <p>So, why do these environments behave so differently?<br>
  This makes me believe that there must be a way to change how PHP interprets relative paths. I am currently working with a 6GB+ PHP project that is written like the example above, and I really need to avoid the amount of effort that it'll take from me to rewrite every include/require statement (using <code>dirname(__FILE__)</code> or so), as well as the git merge conflicts this <em>might</em> cause.  </p>
  
  <p><strong>EDIT</strong>: I've just remembered I actually had already asked this question here: <a href="https://stackoverflow.com/q/32660865/3471286">PHP: include inside included file</a></p>