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

fsdolphin's avatar

Why .env and .env.example in fresh installations

Hi,

Why is that we get both .env and .env.example in a fresh new Laravel installation? Is there any reason why if you only need the .env file?

Thanks

0 likes
5 replies
d3xt3r's avatar

.env as it should be is out of version controlled and ignored when you push your project to any repository. This is for your own safety.

.env.example which contains very generic information is copied as .env on fresh install and a few changes made. ex APP_KEY

1 like
fsdolphin's avatar

Ok, if I understand this correctly is because .env gets ignored when commiting to Git but not .env.example. In other words it is a way to provide a file with most of what other people working on the same project will need without exposing personal info, am I close?

christopher's avatar

Exactly -

And of course the .env file is directly used by Laravel. The .env.example is the same as like the wp-config-sample.php file in Wordpress. A Blueprint for your Config File.

1 like

Please or to participate in this conversation.