I am sure that many PHP developers that a new to the World of Mac development are relieved when they realize (or already know) that PHP is already installed on their Mac by default. But the time and setup to get Apache2, PHP and MySQL to interact together, in an easy manage fashion might be a little harder in the beginning. If you are the type of user that is just doing some local web development and then moving it to a live server or maybe a staging server it is worthwhile to just go and download MAMP. MAMP as you probably have guessed stands for Macintosh-Apache-MySQL-PHP. This is an all in one package that allows you to install all of these great products by seriously just draggins MAMP over to your applications folder. It is configured to use it’s own PHP, MySQL and Apache2 installation (even if you already have some of these running on your machine), which is very handy if you don’t want to disturb your already existing configurations. MAMP is configured to have Apache listen on port 8888 and MySQL listen on port 8889, which unless you have changed your existing installs defaults should not cause a conflict. At this point if you have dragged MAMP to your applications you are absolutely ready to go (easy right?). At this point you can start MAMP. Once it is started it should bring up a browser window (in whatever browser is your default, Safari, Firefox, etc.) This will serve a few purposes, A) that MAMP is running properly and B) allow you to work with MySQL via a built in PHPMyAdmin installation. From here you should be good to go to start developing on your own. I have a few additional modules that I would like to discuss.
XDebug is a great module for helping you analyze PHP error messages. While there is no binary that was designated for for Mac, if you Google the subject you will discover some workarounds. Trust me this is totally worth it. If you download the PHP Remote Debug tools for Komodo it will work . I have only posted the x86 version for Mac, but their are ones if you are still running a PowerPC machine. At this point we need to copy the file over when you extract the zip file you will be presented with a series of folders, the one we are concerned with is the 5.2folder. Inside of it will be a single file which is the extension we need.
Copy it over to:
Then we need to open up the php.ini file which is located in:
Add the following lines to the end of the file:
Once you have completed this all you need to do is verify that x-debug has been loaded which you can do in two ways, A) run a page with phpinfo() on it and you should see XDebug on there OR B) write some bad code (how hard can that be) and verify that you now have fancy looking errors.
At this point you are ready to develop. If you don’t have a preferred IDE for PHP check out Eclipse with PDT or Zend Studio for Eclipse. Try loading up your favorite Framework and get coding. If you don’t have a favorite framework come to OrlandoPHP on April 22nd for a discussion on PHP Frameworks.