-
Notifications
You must be signed in to change notification settings - Fork 28
[Proposal] Dotenv implementation #292
Comments
Just set the requirements in your (new Dotenv(base_path('.env')))->required([
'SERVICES_STRIPE_PUBLIC',
'SERVICES_STRIPE_SECRET',
'SERVICES_EASYPOST_SECRET',
'MAIL_DRIVER',
'MAIL_HOST',
'MAIL_PASSWORD',
'MAIL_USERNAME',
]); |
That's all fine @Garbee but it's a bit hacky to have to create a new instance of |
What would a good solution look like to the problem look like to you? |
What would be nice would be to have that initial instance of
|
You should use cached configurations in production, and dotenv will never be loaded in Laravel 5.2 (and newer). This means that some kind of environment-validation function should only execute when the config is cached; and not on normal requests. Relevant comments: |
Description:
I would like to suggest making available within the bootstrapping process the instance of Dotenv used to load environment variables and provide a mechanism to add and enforce validations on the .env file using the
Dotenv
builtin validators.Currently the environment variables are loaded within the
bootstrap()
method of theIlluminate/Foundation/Bootstrap/DetectEnvironment.php
class using(new Dotenv($app->environmentPath(), $app->environmentFile()))->load();
. The object instance is thrown away and doesn't give developers an easy opportunity to enforce environment variable validations such asrequired()
,notEmpty()
,isInteger()
orallowedValues()
.The text was updated successfully, but these errors were encountered: