I use Azure to deploy my code, so I'm using server's variables to save important settings (like client_id and client_secrets).
$_SERVER['APPSETTING_Imgur_Client_Id'];
Set Azure Application Environment variables
I would like to use the same mecanism in my development environnement (Windows), by setting Environnement variables (directly to windows) and use them in my app.
So I have defined 2 Windows Variables (system properties->Environment Variables->User Variables):
Set Windows's Evironment variables
But thoses variables aren't available through $_SERVER['APPSETTING_Imgur_Client_Id']; (with php -S [::]:80 index.php cmd).
I got only default $_SERVER variables.
So I'm askying:
How to read thoses Windows's evironment variables with php?
If we can't how to add custom $_SERVER variables (without using the php application code).
I'm using:
PHP 7.1.10
&
Windows Server 2016
I have changed the locations of variables (now under System variables) and restarted my computer.
But after that, even with getenv('APPSETTING_Imgur_Client_Id'') or $_SERVER I can't access to my custom variables.
But with command line php -r 'var_export($_SERVER);' I can see my variables
If I want to edit my code, I clone the repo and launch the webserver from the local directory with php -S [::]:80 index.php.
It seam that the php -S command doesn't pass windows environment.
Thanks you.
Edit: Solution:
use getenv see picture below:
getenv('somevar')works, not$_SERVER['somevar']. Should I roll back to previous question ? Or should I post an answer ? thanks a lot.