Is this file an included file?
<p>Is there any way to determine if the current file is the "root" file (requested by apache, or ran via the CLI) or if it is an included file?</p>

<pre><code>basename($_SERVER['SCRIPT_FILENAME']) != basename(__FILE__) 
</code></pre>

<p>Would work, but it only works based on filenames, not the whole path, so kinda hacky. I'd prefer if there was a nicer, and more elegent way to do this.</p>

<hr>

<h1>Bit of context</h1>

<p>I'm writing a PHP 5.4+ API framework named <a href="http://github.com/nathggns/Scaffold" rel="nofollow">Scaffold</a>, which is extremely useful for the <em>api first</em> methodology. The current issue is, is that many people who write an <em>api first</em> application, use their api via a class in the application.</p>

<pre><code>$user = Scaffold::get('/users/nathaniel');
</code></pre>

<p>A nice way to do this, is if that was the actual api, rather than subsequently sending a web request to the server. That way, you avoid the overhead of the HTTP protocol. </p>

<p>I have a pretty good idea on how to do that, but the problem is, I need to know if I should send the response to the browser (encoded and all) or wait for a manual call of <code>Scaffold::request</code> (or any of it's aliases, <code>Scaffold::get</code> being just one of them.</p>

<p>The way I've decided to do this, is to check if the root file of the application  (the file usually requested via apache) was actually requested, or was included by a different file.</p>
