Puneet Kushwah
Puneet Kushwah

Reputation: 1600

laravel 5.8 returning false on getenv

I have updated application to Laravel latest version 5.8 and after update the getenv() function which returns env file variable value is returning false.

However when i used env() I am able to get the env variable value.

I have followed the official documentation and nothing is there which suggest to change from getenv() to env().

https://laravel.com/docs/5.8/configuration

Here suggesting to change to env from getenv()

PHP Dotenv

Please suggest if i need to change every reference of getenv to env or there is another way out.

Upvotes: 0

Views: 3167

Answers (3)

Felix Coker
Felix Coker

Reputation: 61

Try clearing your cache php artisan config:clear, php artisan cache:clear

Upvotes: 0

svikramjeet
svikramjeet

Reputation: 1945

There was specific version of laravel (5.8.4) where getenv was returning false, this has been updated in 5.8.5 or above.

Please check here

Upvotes: 0

Maike Nunes
Maike Nunes

Reputation: 31

The correct way to do it is by changing from getenv to env. Also, getenv doesn't have a second parameter to set a default value.

Upvotes: 2

Related Questions