i have a php cli command problem with Mamp pro. My problem is that the exec inside a php script and in the terminal are different. I explain:
when i execute this command => which php
In the mac terminal:
I get this path: /Applications/MAMP/bin/php/php5.6.2/bin/php
That is normal because i change the path in my .bash_profile file like this:
export MAMP_PHP=/Applications/MAMP/bin/php/php5.5.18/bin export PATH="$MAMP_PHP:$PATH"
In a navigator:
with this line inside a php script: <?php echo exec("which php"); ?>
I get this path: /usr/bin/php
Same result but more detailed with the command => php --ini
In the mac terminal:
Configuration File (php.ini) Path: /Applications/MAMP/bin/php/php5.5.18/conf Loaded Configuration File: /Applications/MAMP/bin/php/php5.5.18/conf/php.ini Scan for additional .ini files in: (none) Additional .ini files parsed: (none)
In a navigator:
Configuration File (php.ini) Path: /etc Loaded Configuration File: /etc/php.ini Scan for additional .ini files in: /Library/Server/Web/Config/php Additional .ini files parsed: /Library/Server/Web/Config/php/php.ini
And the more strange is when in write a php file with this code inside:
<?php var_dump(shell_exec("which php -v")); phpinfo(); ?>
and i launch this script in the terminal and in the navigator too. I got this:In the mac terminal:
Launch with : php -f /Users/tm/Sites/test.com/test.php
Result: /Applications/MAMP/bin/php/php5.5.18/bin/php PHP Version => 5.5.18
In a navigator:
Result: /usr/bin/php PHP Version => 5.5.18
So it seems that a php script launched from the navigator use the right version of php because the php info return the right version (5.5.18) but the cli of this php script use another php and this is my problem. But when this script is launched from the terminal all is as expected.