Skip to content
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

Support cases where .env doesn't exist. #8

Open
christopher-francisco opened this issue Oct 27, 2016 · 3 comments
Open

Support cases where .env doesn't exist. #8

christopher-francisco opened this issue Oct 27, 2016 · 3 comments

Comments

@christopher-francisco
Copy link

I'm mostly working on setups where the .env file works as a quick environment variable definition helper for development purposes, but on QA/staging/production servers we mostly use the environment variables defined on the system itself.

It'd be great to support cases where if the .env doesn't exist, the system doesn't crash, kind of the way Laravel implements it on its bootstrap process.

I'm willing to push a PR if this is OK, let me know 😄

@abacaphiliac
Copy link
Owner

yes this sounds like a great new feature. i can add some diagnostic checks in my applications that require the env file. i like the idea.

let me know if you have any questions or ideas about the unit tests : )

the existing ModuleTest triggers the ModuleManager, giving coverage over init and bootstrap. it's a collaboration test and pretty high level. up to you if you want to do a low and/or high level test.

@christopher-francisco
Copy link
Author

christopher-francisco commented Oct 27, 2016

Given DotEnvFactory re-throws the exception throw by DotEnv when there is no file found (InvalidPathException), I can't think of a different way other than removing those throws.

I tried using a boolean flag to support both cases, required and non-required .env; but the problem is that flag can't be injected from a config file (because dotenv should be initialized before the config files are merged, so that it can be read).

I'm kind of in a dead-end.

Edit 1: maybe said flag can be read from application.config.php ?

@abacaphiliac
Copy link
Owner

i think we're on the right track in our conversation on your request: #9

here's how i'm thinking about solving the .env requirement/suggestion using Zend's diagnostic tools: #11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants