MacOS – Need some basic enlightenment about using PHP

homebrewmacosPHP

Actually I have been programming in PHP for a while, but my experiences about PHP is through VPS or some local environment like XAMPP.
I was trying to install xDebug/homebrew when I come across this
enter image description here

It says "if you are on PHP 5.3", only after reading this did I realize I already had PHP "installed" on my Mac(I think it comes with Mac OS) and this is where I got confused. I need something clarified:

1)I have XAMPP on my Mac, does its PHP interfere with what comes with Mac?

2) If I install Apache on my Mac, does it have its own PHP too? And after installing it, I will be able to use my Mac as a server right? What does this have to do with the server that is already running through XAMPP?

3)Back to what I was doing (installing xDebug), I think I need to install xdebug on xampp's PHP, but following this instructio, it seems to me that I will only install it to Mac's PHP. If this is true, how do I install xDebug to XAMPP?

Best Answer

  1. To figure out whether you have several PHP installed, you may try to run from shell:

    $ which php -a

    If you got one - then you are fine.

    If you discovered, that the first line goes not the one which you installed, ensure that you are using the brew version, by placing /usr/local/bin before /usr/sbin in your PATH:

    PATH="/usr/local/bin:$PATH"

  2. and questions #3: it seems you are confused. XAMPP already includes Apache, so you don't need to install anything separately. XAMPP is an Apache distribution containing MariaDB, PHP, and Perl. You may add xdebug to XAMPP package, by reading one of tutorials for OSX.