PHP 5.4 gave as a few new features, I was a bit blah at first until I got news about the built-in webserver - YES!!! Well that was like a year ago and all .NET and SharePoint development have consumed the most of my life, until now!
Installing (or upgrading) your Mac OS X box to use PHP 5.4
Alright, this is simple and only takes a few minutes. First up install the new version of PHP 5.4, I used the routines from http://php-osx.liip.ch/, really sweet! Just do this
sudo curl -s http://php-osx.liip.ch/install.sh | bash -s 5.4
This installed PHP 5.4 into this folder, you should probably verify that you got the same path
/usr/local/php5-20130210-223618/
Setup the built-in Apache to use PHP 5.4
Still in the terminal? Good, lets open the config for apache
sudo nano /etc/apache2/httpd.conf
Locate the LoadModule for PHP, it's usually in the end of the list of LoadModules. Uncomment the old php module by putting a hash sign (#) in front of it and put the new module on a new line, in my case it looks like this
LoadModule php5_module /usr/local/php5-20130210-223618/libphp5.so
Save and exit (CTRL + o + enter) (CTRL + x), restart apache
sudo apachectl restart
Set the PHP library path
We do this so the new PHP binaries will be default on command line execution, it can be done in a numerous of ways. Here is my approach.
sudo nano /etc/paths
Enter the path to the bin folder of your new PHP library, mine now looks like this.
/usr/local/php5-20130210-223618/bin/ /usr/bin /bin /usr/sbin /sbin /usr/local/bin
Save and exit, you should probably restart bash at this point.
Simple test
Create and open a file, this is the default location of the webserver in os x
sudo nano /Library/WebServer/Documents/php.php
Enter the following
<?php phpinfo(); ?>
Save and close, go to your file by entering something like http://localhost/php.php