How to store multi line config in .env? |
How to store a multi line key in the .env file
publicKey = <<<EOD -----BEGIN PUBLIC KEY----- ZZzzZZZZZzZZzzzZZZZZZZZZZzZzZZJBZZZlzGDzCzzZZZZzZzZzzzzzzzzzzZZZZ M9NYvZZZZZzzz/ZZZZZZZZZoDShgMTGirZZZzzzzzZzzZ/EypXBPHQ08CZzZZZZ== -----END PUBLIC KEY----- EOD;
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. (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. 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. |
Welcome Guest, Not a member yet? Register Sign In |