I was also having this issue and found the solution in a single character in php.ini: be sure that the variables_order setting begins with "E" (mine was missing):
variables_order = "EGPCS"
It looks like the issue was due to PHP's $ENV global being left empty due to this setting. I'm guessing this is because of the default "production" php.ini that ships with the PHP distributed with MacPorts.