Using MAMP + MAMP Pro 3.5 for local development. Using the envvars
file, I'm supplying my own PATH, that is different from the PATH for any other user or purpose. Let's pretend it's /my/unique/custom/path
.
I put the following file on my local development site:
<ol>
<li><?php print $_SERVER['PATH']; ?></li>
<li><?php print $_ENV['PATH']; ?></li>
<li><?php print exec('echo $PATH'); ?></li>
</ol>
And this is the result:
- /my/unique/custom/path
- /my/unique/custom/path
- /usr/gnu/bin:/usr/local/bin:/bin:/usr/bin:.
So PHP sees that the PATH environment variable is supposed to be mine, but somehow it's not the one actually used to run commands.
What could be causing this? Apparently that #3 PATH is the default path for bash, if you don't set one, I think? What could be causing it to get either deleted or never set, given that PHP sees it correctly?
UPDATE 1:
Running print_r(shell_exec('env'))
gets me this and nothing more:
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
PHP_FCGI_CHILDREN=4
PWD=/path/to/website/files
SHLVL=1
PHP_FCGI_MAX_REQUESTS=200
_=/usr/bin/env
Pretty bare. Seems like that $_ variable is a big clue, but I don't yet know to what.
UPDATE 2:
Okay, so it ends up that a bare environment is normal. This is why you set environment variables in envvars
in the first place. But envvars
is clearly working, or else that path wouldn't show up in $_SERVER
. So something is happening between the time envvars
is run and the time I run my own code.