1

I need to modify the $PATH on my mac so that PHP system() calls will recognize it.

So far I've edited the /etc/profile to include the line:

export PATH=$PATH:/Applications/MAMP/Library/bin

but if I do system('echo $PATH'); in PHP the new path doesn't show up.

Yarin
  • 173,523
  • 149
  • 402
  • 512

1 Answers1

2

Use the putenv function. For example, to add the current directory to the $PATH, one could use the following code :

<?php
putenv('PATH='.getenv('PATH').':.');   
echo shell_exec('echo $PATH'); /* Prints the expected result */

http://php.net/putenv

Artefact2
  • 7,516
  • 3
  • 30
  • 38
  • 1
    @Artefact2- Thanks, but I'm looking for a way to modify the system environment permanently, not through code. – Yarin Feb 28 '11 at 16:09