Php – Can’t change path location of PHP on mac os x snow leopard

bashbashrccommand-line-interfacepathPHP

I have XAMPP installed on my mac, and I want to make command line PHP use the same executable as XAMPP since I've customized that php's php.ini file.

The php binary I want is located at:

/Applications/XAMPP//xamppfiles/bin/php

A quick check of where my CLI php is coming from says:

Casey-Flynns-MacBook-Air:~ casey$ whereis php
/usr/bin/php

I've tried adding the following line to my ~/.bash_profile:

export PATH=/Applications/XAMPP//xamppfiles/bin/:$PATH

And a quick test of my $PATH global says its:

    Casey-Flynns-MacBook-Air:~ casey$ echo $PATH
/Applications/XAMPP//xamppfiles/bin/:/Applications/SenchaSDKTools-2.0.0-Developer-Preview/jsbuilder:/Applications/SenchaSDKTools-2.0.0-Developer-Preview/command:/Applications/SenchaSDKTools-2.0.0-Developer-Preview:/opt/local/bin:/opt/local/sbin:/sw/bin:/sw/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin:/usr/X11/bin:/opt/local/bin:/usr/X11R6/bin:/Users/casey/.ec2/bin

But still when I execute 'php' from my command line it uses the binary I don't want. Anyone know what might be going on?

Best Answer

See man whereis:

The path searched is the string returned by the sysctl(8) utility for the ``user.cs_path'' string.

Which is on my Mac OS X:
$ sysctl user.cs_path
user.cs_path = /usr/bin:/bin:/usr/sbin:/sbin

Rather use which to verify what your shell would use:
$ echo $PATH
/Users/xyz/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
$ which php
/Users/xyz/bin/php

Still I think it's not nice to have two programs with the same name in your $PATH, but I see no better solution (I don't think you can get rid of the preinstalled php and removing /usr/bin from PATH is also not really good...).