php - Set json file as environment variableGet the solution ↓↓↓
Please could I have step by step instructions to set the authentication.json file as environment variable instead of having the json file in my project location For example:
$jsonAuth = getenv('JSON_AUTH');
Running CentOS Linux 7.9.2009 with Apache
Ideally, you want to encode the json to base 64. Its easier as base64 gets rid of the printable characters that need to be escaped. After that, you can do the following in PHP.:
$jsonAuth = json_decode(base64_decode(getenv('JSON_AUTH')), true);
- Make sure you have mod_env installed (it usually is, but double check this).
- Find the
<VirtualHost>for your application, and add
SetEnv JSON_AUTH your_token_here, and as many other auth variables you need to set.
- Reload Apache (
apachectl -k gracefulor via init.d).
- Read out the variables using
$jsonAuth = apache_getenv('JSON_AUTH');.
Share solution ↓
Link To Answer People are also looking for solutions of the problem: a non well formed numeric value encountered
Didn't find the answer?
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Write quick answer
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.