Replies: 1 comment 1 reply
-
Sounds like the logical conclusion to have also that after we already got this functionality for config variables, even though, env variables will almost exclusively be used in config files 🤔 |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi there !
When upgrading my application from Laravel 10 to 11, I faced an error because an environment variable was used as an integer, but not defined in my
.env
, which resulted in an empty string.I then though it could be nice to have something like this :
env()->int('MY_ENVIRONMENT_VARIABLE')
, and some equivalents for float and datetime (returning a Carbon instance).The implementation is pretty straightforward, just adding a wrapper around
Illuminate\Support\Env::get($key, $default)
with the corresponding cast :And a little modification of the
env()
helper inIlluminate/Support/helpers.php
:Any thoughts about this ? I'd be glad to talk about it 😄
Beta Was this translation helpful? Give feedback.
All reactions