How can I require_once a file in Yii2 which is located higher in my directory tree than the root directory of the app?
<p>Yii2 has no problem addressing namespaces outside of the active application directory tree. However I would like to use a require_once statement to get a file holding just constants (i.e., a long list of define(CONSTANT, value) statements) from a location that both the frontend and backend Yii2 advanced template application instances can share.</p>

<p>Right now I am using:</p>

<pre><code>require_once '..\..\common\config\keywords.php';
</code></pre>

<p>but this fails when I migrate my application from the Windows development environment in which I am working to the Linux environment where it runs in production, possibly because the relative addressing prefix ('..\..\') isn't something Linux can interpret (?).</p>

<p>Ideally I would like a solution that uses an alias or in some way does not depend on relative or absolute paths. But while this works to include the file when it is located <em>under</em> the base application path:</p>

<pre><code>require_once Yii::$app-&gt;basePath.'\config\keywords.php';
</code></pre>

<p>.. it still doesn't give me a way to address a directory from a starting point <em>higher</em> than the application base path.</p>

<p>This seems like a common problem that anyone trying to use a shared file of constants would have. How do experts solve it? Am I missing a more elegant approach?</p>