Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MrMoto9000's avatar

Laravel 8 is using .env.local instead of .env?

Help, I've encountered the strangest oddity. As far as I'm aware Laravel should only use .env, but my project has decided to use .env.local. I've never seen anything like it. If I change the values in .env.local my app will break, but if I change the ones in .env nothing happens. As great example is the DB_PASSWORD.

My config/database.php looks like you'd expect it to:

'password' => env('DB_PASSWORD', ''),

I don't understand what's happening. I've composer dump-autoload and artisan optimize:clear. What's going on?

0 likes
5 replies
MrMoto9000's avatar

I fixed it by renaming .env.local to .env.local.example. Now it reacts to values in .env.

This happened on two machines with two different devs. So odd.

Snapey's avatar

Laravel will use an .env file that matches the environment, if one exists

Sinnbeck's avatar
Sinnbeck
Best Answer
Level 102

@JohnnyW2001 I don't think this is a laravel thing. Most frameworks I know use .env.local to allow overwriting env variables locally

A few examples

https://create-react-app.dev/docs/adding-custom-environment-variables/#adding-development-environment-variables-in-env

https://symfony.com/doc/current/configuration.html#overriding-environment-values-via-env-local

My guess would be that laravel supports how env files works everywhere else, but does not mention it as the env file isn't in git, and the local version therefor is redundant

1 like

Please or to participate in this conversation.