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

[5.8] Upgrade to dotenv v3 #27044

Merged
merged 1 commit into from Jan 3, 2019

Conversation

Projects
None yet
3 participants
@GrahamCampbell
Copy link
Member

GrahamCampbell commented Jan 3, 2019

What's new in dotenv v3 that will affect Laravel? The safeLoad method was added in v2.5.0 (#242), and first-class support for multiline variables has landed in v3.0.0, so that SSH keys and the like can be pasted as is, without adding pseudo-newline characters (#301).

Finally, a consequence of the improvements in (#300) mean that the new way to construct a Dotenv object is via it's static create method.

@taylorotwell taylorotwell merged commit 8050ad4 into master Jan 3, 2019

4 checks passed

continuous-integration/styleci/pr The analysis has passed
Details
continuous-integration/styleci/push The analysis has passed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details

@driesvints driesvints deleted the dotenv branch Jan 3, 2019

@ankurk91

This comment has been minimized.

Copy link
Contributor

ankurk91 commented Jan 4, 2019

Is it possible to add support for required variables in laravel.

https://github.com/vlucas/phpdotenv#requiring-variables-to-be-set

@GrahamCampbell

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jan 4, 2019

Yes, you can define your own boostrapper, instead of using the default, then you're free to do whatever. :)

@GrahamCampbell

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jan 4, 2019

Basically, just replace

\Illuminate\Foundation\Bootstrap\LoadEnvironmentVariables::class,
with your custom class, and then you can do whatever you like with validation in there. :)

@GrahamCampbell

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jan 4, 2019

@ankurk91 Thinking more about this, actually a custom boostrapper in the current framework is actually a bit of a pain. While it's nice and easy to replace it in your app (in the two kernels), it's actually also hard coded within the application's afterLoadingEnvironment method, which is used all over the testing helpers of the framework, which is unfortunate.

I'm gonna have a think about how we can make this nice to use.

@ankurk91

This comment has been minimized.

Copy link
Contributor

ankurk91 commented Jan 4, 2019

@GrahamCampbell

Thanks for looking into it.

May be if we can add something like this our .env

APP_NAME=Laravel

REQUIRED_VARS=DB_HOST,DB_PORT,DB_PASSWORD

Then framework can use this array like

$dotenv =  Dotenv::create(/* ... */)

$requiredVars = explode(",", env('REQUIRED_VARS'))
$dotenv->required($requiredVars)->notEmpty();
@GrahamCampbell

This comment has been minimized.

Copy link
Member

GrahamCampbell commented Jan 4, 2019

May be if we can add something like this our .env

I think I'd prefer the user defined implementation still.

I'm gonna have a think about how we can make this nice to use.

I've been looking into this some more, and this bootstrapping callback is not used anywhere actually, by the framework core, so as long as you don't use it in your code, it should be fine. If you'd want to use that method to register a callback, it can be done, but call afterBootstrapping instead, proving the name of your bootstrapper to param 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment