views:

3052

answers:

2

Does MAMP come with the PHP CLI installed? I am trying to run a script from the command line, but using a Mac, with MAMP, and not knowing much about PHP CLI is making it difficult.

How should I set up my environment so that I can use the PHP CLI with MAMP?

A: 

Yes, I think it is here: /Applications/MAMP/bin/php5/bin/php

You can either add /Applications/MAMP/bin/php5/bin/ to the front of your path or create a symlink in /usr/bin (there probably is one there already for the default PHP installation)

Tom Haigh
so would the PHP CLI be built in to /Applications/MAMP/bin/php5/bin/php because I don't see anything about PHP CLI in /Applications/MAMP/bin/php5/bin
Andrew
I thought that the php binary was in there on mine, but maybe not. It will just be called 'php'. I will have a look on my Mac later.
Tom Haigh
+1  A: 

Run this in your Terminal:

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

Should do the trick. It will - as Tom Haigh mentioned - add the MAMP PHP executable to the path so you can use "php" instead of the full path.

phidah
What can I do to check if it's working correctly?
Andrew
php -i | grep php.ini - this should give you the MAMP php ini location if it is working properly, rather than /etc
Tom Haigh
Andrew, you can use "which php" to get the path of the php executable that the php command will use.
phidah