title: get parent folder paths with php
body: <p>I am working on my first MVC framework, and want to define 4 constants for BASE_PATH, APP_PATH, LIB_PATH &amp; PUBLIC_PATH. My file structure looks like this:</p>
  
  <pre><code>/
  /app
      /controllers
      /models
      /views
  /config
  /db
  /lib
  /public_html
      /css
      /js
      /img
  </code></pre>
  
  <p>My <strong>index.php</strong> file is located in the <strong>public_html</strong> directory. And currently has the following code:</p>
  
  <pre><code>error_reporting(E_ALL);
  define('BASE_PATH',dirname(realpath(__FILE__)) . "/../");
  define('APP_PATH',dirname(realpath(__FILE__)) . "/../app/");
  define('LIB_PATH',dirname(realpath(__FILE__)) . "/../lib/");
  define('PUBLIC_PATH',dirname(realpath(__FILE__)) . "/");
  
  require LIB_PATH . 'core.php';
  </code></pre>
  
  <p>This works, but I feel like there must be a better way of doing it without all of the "..". Any suggestions or is this the best way of going about it? Let me know. Thank you!</p>
  
  <hr>
  
  <p><strong>ANSWER</strong></p>
  
  <p>Thank you to @fireeyedboy and @KingCrunch, I have come up with the solution I was looking for. This is my final code:</p>
  
  <pre><code>define('PUBLIC_PATH', dirname(__FILE__) . "/");
  define('BASE_PATH', dirname(PUBLIC_PATH) . "/");
  define('APP_PATH', BASE_PATH . "app/");
  define('LIB_PATH', BASE_PATH . "lib/");
  </code></pre>