PHP include file strategy needed
<p>I'm in the process of setting up a php project, but am not very familiar with how to properly use php's include/require commands.  My layout currently looks like this:</p>

<p>/public   --apache points into this directory<br />
/public/index.php<br />
/public/blah/page.php<br />
/utils/util1.php       -- useful classes/code are stored in other directories out here<br />
/dbaccess/db1.php  </p>

<p>dbaccess/db1.php  </p>

<pre><code>require '../utils/util1.php
</code></pre>

<p>public/index.php</p>

<pre><code>require '../dbaccess/db1.php'
</code></pre>

<p>public/blah/page.php</p>

<pre><code>require '../../dbaccess/db1.php'
</code></pre>

<p>The problem is this from the php 'include' documentation:</p>

<blockquote>
  <p>If filename begins with ./ or ../, it is looked only in the current working directory</p>
</blockquote>

<p>So public/blah/page.php fails because it includes dbaccess/db1.php which blows up when it tries to include util1.php.  It fails because it's relative path is from the original script in public/blah/, not from dbaccess/</p>

<p>This seems pretty stupid -- db1.php has to just know where it's being included from which isn't going to work.</p>

<p>I've seen strategies like this:</p>

<pre><code>require_once dirname(__FILE__) . '/../utils/util1.php');
</code></pre>

<p>That apparently works since now the path is an absolute path, but just seems really bizarre to me.  </p>

<p>Is that normal?  Should I continue down that path or am I missing something obvious here?</p>
