Running PHP from XAMPP manually through Terminal

I have been spending some time with CakePHP today and in order to execute php through the terminal to get it to connect to XAMPP’s correct mysql port, I need to run terminal. The problem is if you execute plain old php in terminal like “php –info” or “which php” you’ll get a response from the default installation of PHP on your mac. You need to run PHP as if it’s being run on the XAMPP environment.

In order to do this, make sure you execute php from the bin directory of XAMPP.

/Applications/xampp/xamppfiles/bin/php --info

This way, your terminal application is executing PHP with the correct settings to do all the things it needs to do to connect to its version of mysql and write the correct files in your XAMPP environment (when you’re “baking” with cakePHP).

One thought on “Running PHP from XAMPP manually through Terminal

  1. may i adding something.
    If you want to access it globaly using command `php`, just do this command

    sudo ln -s /Applications/xampp/xamppfiles/bin/php /usr/local/bind

    test in terminal:
    `php -v`

Leave a Reply

Your email address will not be published. Required fields are marked *