Search code examples
laravelcentosenvironment-variables

Special chars in Laravel .env file


I'm having troubles using special chars in values of a Laravel .env file. For example:

DB_PASSWORD=some#secret

Now the env('DB_PASSWORD') is just 'some'

Is there a way to escape characters or some other method to use values like this in the .env file?

In case it makes a difference, my server is running on CentOS 8.2.2004

UPDATE: Forget the whole thing. It turned out it was a different issue altogether. Answer below is correct on the actual question though.


Solution

  • # is for commenting in a .env file. If you want to use # as a value, you need to wrap it in ":

    DB_PASSWORD='some#secret'