Accessing system variables through HHVM
Problem: I want to access environment variables through HHVM that aren’t typically exposed to a default php setup
Context: I rely on a couple of system variables to provide dynamic configuration options to a Laravel4 project running in a Docker container. I want to connect to a mysql DB running in another docker container that exposes a random IP address on startup. This IP address is passed into the Laravel4 container using
--link options for Docker and automatically exposed as a system variable in the Laravel-4 container.
Previous approach: When using php-fpm, I could expose system variables created by Docker to php using the
www.conf file like so, and then just use getenv(‘VAR_NAME’) to get the variable in my php code.
However, with HHVM, I cannot figure out how to access a “non-standard” environment variable. There seems to be no equivalent to
www.conf that I can locate. Has anyone attempted this before? Is it possible to access system variables that are external to PHP using HHVM? Is there something specific to HHVM’s configuration and I just can’t find it in the docs?
Additional Info: I am behind Nginx here. I don’t think fastcgi-param directives will work in my case, but I may just be doing it wrong. If anyone has accomplished what I’m trying to do using fastcgi-params, I’m fine with that approach also.
One Solution collect form web for “Accessing system variables through HHVM”
fastcgi_param should work the exact same way in HHVM (assuming you are using HHVM as a fastcgi server, which you should be).