In 2022 both separate line comments and inline comments are supported.
Line started with #
symbol is a separate line comment. See the docs. Inlined #
sign denotes the start of an inline comment (thanks to @reddisht to note this in comments).
For vlucas/phpdotenv the same situation.
Here is the example for both:
# This is the seprate comment line
NODE_ENV=stage
APP_VERSION=1.0.0 # This is an inline comment
The "#"
(double quote wrapped hash symbol) is not treated as a comment even at line beginnig starting from v15.0.0 (thanks to @walkingbrad commented this below).
There are parsing peculiarities you may find good to knoww described in this docs section.
Yet do not forget that some packages like e.g. mrsteele/dotenv-webpack (at least v7.1.1) do not support inline comments and you can face your application’s unexpected behaviour putting inline comments in your .env
files.