You can comment like this :
# this is a comment
VAR="value" # comment
VAR=value # comment
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
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.
You can comment like this :
# this is a comment
VAR="value" # comment
VAR=value # comment
Please or to participate in this conversation.