I’ve been able to find information on how to use config vars in Heroku for Python, node.js, and some other languages, but not for PHP. Can you use them with PHP, or is it not supported?
This article shows how to do it for Python, Java, and Ruby, but not PHP.
Advertisement
Answer
Config vars on heroku manifest themselves as environment variables, so you should be able to access them from php like you would any other environment variable, eg. using getenv
.
First, set the variable from your console:
heroku config:set MY_VAR=somevalue
Then, access it from your code:
$my_env_var = getenv('MY_VAR');