PHP's dotenv package does not seem to support multi-line environment variables.
You should ideally keep your .pem file as a file and reference it by path like e.g.:
and in the config:
return [ //... "key" => file_get_contents(env('PEM_FILE'))
This makes sense since generally certificates should generally go in the dedicated certificates path on the server. If you cache the config then the actual contents of the .pem file are only read once on deployment.
However if you must put it in dotenv then you can do:
PEM_KEY="-----BEGIN RSA PRIVATE KEY----- … -----END DSA PRIVATE KEY-----"
return [ //... "key" => str_replace("\ ", " ", env('PEM_KEY')),
Since the key is generally base64 I don't think there's a chance