Upgrading PHP in MAMP

I wanted to take advantage of PHP 5.3’s new
1namespace
feature but in my localhost environment, I use MAMP. Upgrading PHP proved a little tricky, but actually very easy. The tricky part was figuring out how to make it work, but on the whole, it’s not too bad.
First, run the
1phpinfo()
function in a PHP script on your localhost or go to PHPMyAdmin and hunt down the configuration page. You should see a large chunk of configuration markup at or near the top:

12345678910111213141516171819'./configure' '--with-mysql=/Applications/MAMP/Library'
'--with-apxs2=/Applications/MAMP/Library/bin/apxs'
'--with-gd' '--with-jpeg-dir=/Applications/MAMP/Library'
'--with-png-dir=/Applications/MAMP/Library' '--with-zlib'
'--with-freetype-dir=/Applications/MAMP/Library'
'--prefix=/Applications/MAMP/bin/php5' '--exec-prefix=/Applications/MAMP/bin/php5'
'--sysconfdir=/Applications/MAMP/conf/php5' '--with-soap'
'--with-config-file-path=/Applications/MAMP/conf/php5'
'--enable-track-vars' '--enable-bcmath' '--enable-ftp' '--enable-gd-native-ttf'
'--with-bz2=/usr' '--with-ldap' '--with-mysqli=/Applications/MAMP/Library/bin/mysql_config'
'--with-sqlite' '--with-ttf' '--with-t1lib=/Applications/MAMP/Library'
'--enable-mbstring=all' '--with-curl=/Applications/MAMP/Library' '--enable-dbx'
'--enable-sockets' '--enable-bcmath' '--with-imap=shared,/Applications/MAMP/Library/lib/imap-2006i'
'--enable-soap' '--with-kerberos' '--enable-calendar'
'--with-pgsql=shared,/Applications/MAMP/Library/pg' '--enable-dbase'
'--enable-exif' '--with-libxml-dir=/Applications/MAMP/Library'
'--with-gettext=shared,/Applications/MAMP/Library' '--with-xsl=/Applications/MAMP/Library'
'--with-pdo-mysql=shared,/Applications/MAMP/Library' '--with-pdo-pgsql=shared,/Applications/MAMP/Library/pg'
'--with-mcrypt=shared,/Applications/MAMP/Library' '--with-openssl'

Copy and paste this whole chunk into your text editor and remove the single quotes (search and replace should do it). Look for the flag
1--with-pdo-mysql=shared,/Applications/MAMP/Library
and replace it with:

1--with-pdo-mysql=/Applications/MAMP/Library

If you don’t do this, you might end up with an
1ld: symbol(s) not found
error.
Finally, add the following flag to the end:

1--without-iconv

After you have downloaded the latest PHP release of your choosing from PHP Sources Snapshots,
1cd
to the downloaded directory in Terminal. Paste your reformatted configuration string (all of it, including the beginning
1./configure
command) and run it.
After the configuration phase is finished, run:

12$ make
$ sudo make install

Relaunch MAMP, and you’re good to go.
For you CakePHP users out there, now you can play with Cake3 releases (which apparently will be optimized for PHP 5.3+).