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

chris.schmitz's avatar

Commenting in the .env file

Is there a way of safely commenting in the .env file?

I'm assuming you can just write whatever you want into .env since it's not actually code you're running, it's a text file you're referencing, but I wasn't totally sure so I thought I'd ask.

I was mainly looking to add comments to blank keys I'll be adding into the .env.example file so that other devs know what they're used for and what values to add.

Thanks.

0 likes
7 replies
bestmomo's avatar
Level 52

You can comment like this :

# this is a comment
VAR="value" # comment
VAR=value # comment

Reference.

3 likes
jlrdw's avatar

You realize that env isn't meant for production site.

Please or to participate in this conversation.