Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add a literal quote in Laravel's .env file?

I'd like to add a string value to my .env file that contains quotes like so.

APP_NAME="Hacking"

Laravel assumes the quotes are being used to define the string, but I want the literal quote in the string.

I've also tried the following.

APP_NAME='"Hacking"'

APP_NAME=\"Hacking\"

APP_NAME="\"Hacking\""
like image 581
Mav Avatar asked Nov 09 '18 06:11

Mav


1 Answers

Try this:

APP_NAME='""Hacking""'

or this:

APP_NAME="\"\"Hacking\"\""

The dotenv library removes the outer layer of single or double quotes when it sets the environment variable: https://github.com/vlucas/phpdotenv/blob/fa1a24d/src/Loader.php#L249

Laravel's env() helper removes the outer layer of double quotes when it retrieves the variable: https://github.com/laravel/framework/blob/2ab2fc6/src/Illuminate/Support/helpers.php#L613

like image 167
Travis Britz Avatar answered Nov 08 '22 04:11

Travis Britz