Posts Learn Components Snippets Categories Tags Tools About

How to Comment Configuration in Laravel .env File (Environment)?

Learn how to comment configuration in Laravel .env file

Created on Oct 21, 2021


To comment configuration inside the .env file you can make use of the "#" hashtags character. Since Laravel is using the vlucas/phpdotenv package to parse .env file, based on the documentation it's using the "#" character.
# This is a comment
VAR="value here" # comment here is ignroed
VAR2=value # comment here is ignored
The config above will output the code below.

env('VAR'); // value here
env('VAR2'); // value
To add "#" as a value you need to wrap it with double-quote.
The output will be as follows

env('VAR_HERE'); // #hashtags

If you like our tutorial, do make sure to support us by being our Patreon or buy us some coffee ☕️