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.
Right now I am using:
require_once '..\..\common\config\keywords.php';
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 (?).
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 under the base application path:
require_once Yii::$app->basePath.'\config\keywords.php';
.. it still doesn't give me a way to address a directory from a starting point higher than the application base path.
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?