-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Dotenv] Check required dotenvs #32729
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
Conversation
To me it doesn't look like this change really belongs to the Dotenv component. The component is meant to read environment variables from |
@xabbuh similar features are used e.g in Ruby's gem (https://github.com/bkeepers/dotenv#required-keys) and some PHP libs:
IMHO Dotenv could be one of the best places for this feature as it is used at the beginning of script, where it is possible to prevent further execution of scripts with invalid config. |
Where do you get the list of required vars from in your use case? |
@nicolas-grekas I got some environment variables defined in Apache's vhosts config to verify that request came from internal of external networks. For development purposes adding it to This also can act as an "reminder" for new developers that they need to define missing variables in EDIT: setting environment variables in vhost as above is used e.g. in eZ Publish: https://doc.ez.no/display/EZP/Siteaccess+Matching#SiteaccessMatching-Matchingbyenvironmentvariable |
In any case, the list of required vars needs to be put somewhere. The most logical place is the |
I'm closing to snapshot the state of the PR and related discussion. |
TODO:
Added new method, which checks there are all environment variables defined in project.
This one may be used e.g. to tell other developer to provide all things needed to run app without any missing-envs-caused malfunctions.
It is checking only _ENV superglobal as there may be some vars defined in third-party software (like
SetEnv
in Apache)