-
-
Notifications
You must be signed in to change notification settings - Fork 628
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Question - are there any 'builtin' variables? #550
Comments
No, there are no built-ins, but there may be variables already set outside of your env file that can be access from it. |
Some that are resolved from $_SERVER: https://www.php.net/manual/en/reserved.variables.server.php. |
yeah, it will contain a PWD, but when I played with that one, it tells you the directory of the calling script, not the location of the .env file. I already had a method -- since the calling scripts are generally going to be 'under' the project root -- that will search-up the current path until it finds a .env (in my case, I also confirm with other directories/files such a vendor and composer). But that too can be unreliable as dev environments often use symlinks for local packages who's source code is under a different path. |
I'd still like to upvote this - it would still be nice to be able to get the directory where the .env file was located in other code after the environment was loaded. (I ran into another situation where this would be useful) |
You can save the path to a constant and pass it into |
You give an example that shows setting a 'BASEDIR' then using it ( ${BASEDIR} ) in other variables. Since the .env file is usually placed in the root of a project or package, is there any means to access some kind of built-in that will tell you the directory/path where the .env is located to automagically set a BASEDIR or ROOTDIR using whatever location the .env file is stored?
The text was updated successfully, but these errors were encountered: