1

I'd like to access some config vars in a PHP file on a Heroku web app.
The app runs (and starts) with Node.js and utilizes both Node.js and PHP buildpacks from Heroku.

What I want to happen

I would like to be able to start the app with Node.js and access the environment variables in my PHP file.

What actually happens

When I start the app with Node.js, the config vars are accessible through process.env('SOME_KEY') (in the js file), and when I don't use Node.js and start in PHP the variables are accessible through getenv('SOME_KEY'), but when I start in Node.js getenv('SOME_KEY') (in the PHP file) returns undefined (likewise with $_ENV['SOME_KEY']).

I'd appreciate it if someone could explain why it's not accessible in PHP, if there is a way to make it accessible through PHP, or a way to send the variables from Node.js to the PHP file. Thank you!

jeremye
  • 1,368
  • 9
  • 19
  • Really not working ? Look here https://devcenter.heroku.com/articles/getting-started-with-php#define-config-vars and I think he get it work too -> http://stackoverflow.com/questions/21592832/use-heroku-config-vars-with-php – Simon Franzen May 12 '17 at 10:28
  • 2
    @SimonFranzen I've looked at both, those only talk about starting the app in PHP. My procfile looks like this: `web: node index.js`, and when I start in node.js, the variables are accessible in node.js and not in PHP. If I start in PHP (make an index.php file) and change my procfile to `web: vendor/bin/heroku-php-apache2 /` then the variables will work in PHP. I want the variables to be accessible in PHP after starting in node.js. – jeremye May 13 '17 at 00:58
  • i am trying in php..`getenv('SOME_KEY')` shows empty only..i have to do anything in vendor or composer? @illiteratecoder – lalithkumar Jul 28 '17 at 05:44

0 Answers0