Environment variable in Niginx or using phpdotenv

I am trying to save api authorization key (sensitive information) in an environment variable. I used fastcgi_param inside location ~ .php$ in Nginx configuration. I am calling this variable inside function.php file in wordpress to use the api. Is this secure or should i use phpdotenv php package and create .env file to define the variable. Thanks Nginx: location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass unix:/var/run/php/php8.1-fpm.sock; fastcgi_param API_AUTH 'xxxxxxxxxxxxxxxxxxxx'; } Function.php $auth = $_SERVER['API_AUTH'];

Comment (0)

You’ll be in good company