• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to store multi line config in .env?

#1
How to store a multi line key in the .env file

publicKey = <<<EOD
-----BEGIN PUBLIC KEY-----
ZZzzZZZZZzZZzzzZZZZZZZZZZzZzZZJBZZZlzGDzCzzZZZZzZzZzzzzzzzzzzZZZZ
M9NYvZZZZZzzz/ZZZZZZZZZoDShgMTGirZZZzzzzzZzzZ/EypXBPHQ08CZzZZZZ==
-----END PUBLIC KEY-----
EOD;
Reply

#2
It doesn't look like it is possible. First off, the .env file is processed on a line-by-line basis and unless the line has an equal sign (=) it isn't considered to hold any information about a variable. Second, .env is not a PHP file and so will not be considered by the PHP parser meaning that the heredoc syntax won't be evaluated to the string you need.

In the case of storing an encryption key, I don't think the line breaks are a MUST, so you could try it out as one long line of text without line breaks. See if that's useable by the encryption functions you're using.
Reply

#3
(04-04-2020, 09:01 AM)dave friend Wrote: It doesn't look like it is possible. First off, the .env file is processed on a line-by-line basis and unless the line has an equal sign (=) it isn't considered to hold any information about a variable. Second, .env is not a PHP file and so will not be considered by the PHP parser meaning that the heredoc syntax won't be evaluated to the string you need.

In the case of storing an encryption key, I don't think the line breaks are a MUST, so you could try it out as one long line of text without line breaks. See if that's useable by the encryption functions you're using.


You are correct on your suggestion.

I was pretty tired last nite when I was working on this, and was too tired to try any more, but I just tried your suggestion and it worked perfectly.



jwt.publicKey = "-----BEGIN PUBLIC KEY----- MFwwDQH...Q08CAwEAAQ== -----END PUBLIC KEY-----"



thanks for the help on this.
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme ¬© 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.