Support the ongoing development of Laravel.io →
Configuration Cache

Hi,

when I would get a variables from .env file using env() function, always returns null. I tried cache:clear, config:cache, finally i change in correct php.ini value from variables_order = "GPCS" to variables_order = "EGPCS". From this moment returns $_ENV array of data, but not include data from .env file.

I could't get data from .env anyway. Can anyone help me?

Thanks, have a good day!

Last updated 3 years ago.
0

You need to insert the key in the method, or it only returns an array.

env('KEY'); // **local**

In your .env file:

KEY=local
...

Added Docs Link

Last updated 8 years ago.
0

Sign in to participate in this thread!

PHPverse

Your banner here too?

TBestcz tbestcz Joined 22 May 2016

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.