My current server password is a123!@#ASD
but in .env file #
is used to comment out something. So characters after # in my password are neglected and I can't connect to my server.
Is there any escaping way in .env file so that I can use my current password.
Asked
Active
Viewed 8,401 times
6

ANIK ISLAM SHOJIB
- 3,002
- 1
- 27
- 36
3 Answers
11
As per Laravel Documenation
All variables in your
.env
files are parsed as stringsIf you need to define an environment variable with a value that contains spaces, you may do so by enclosing the value in
double quotes
.
"Laravel" treats #
as comment. So if there is space
or #
in your password then you have to enclosed it in double quotes(""
)
DB_PASSWORD = "a123!@#ASD"

Sehdev
- 5,486
- 3
- 11
- 34
3
You can use ""
like
"a123!@#AS"
Env file will support Quotes. For more details take a look https://laracasts.com/discuss/channels/laravel/beware-in-env-files

Amal S R
- 870
- 7
- 21
1
In a scenario I have something like this with json in .env:
#Parsed by skiping after #: '[{"name":"dummy1",password:"Pass'
destinations=[{"name":"dummy1",password:"Pass#1234"];
#parsed to correct string : '[{"name":"dummy1",password:"Pass#1234"]'
destinations=`[{"name":"dummy1",password:"Pass#1234"]`;
Ref: dotenv vesrion: 16.0.1 https://www.npmjs.com/package/dotenv
backticks are supported (BACKTICK_KEY=`This has 'single' and "double" quotes inside of it.`)

Bibhu Prasad
- 11
- 1
- 2