(Updated 1st May 2010)
With OS X 10.6, Apple ships PHP 5.3 with PEAR, GD and PDO_MYSQL out of the box. Also, everything is now 64bit. This means that the entire effort required to get a working PHP dev environment for my work is now much easier.
/usr/local
Ensure that the following directories exist:
sudo mkdir /usr/local/include sudo mkdir /usr/local/bin sudo mkdir /usr/local/lib sudo mkdir -p /usr/local/man/man1
MySQL
- Download the 64bit DMG version of MySQL 5.1.x (or 5.5.x) for OS X 10.6 from mysql.com and install the pkg, the startup item and the pref pane.
- Add /usr/local/mysql/bin to the path: vim ~/.bash_profile and add:
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH export EDITOR=vim
at top of file. (Note that we set EDITOR whilst we are here so that svn is happy!)
- Set up MySQL root password:
mysqladmin -u root password {new-password} mysqladmin -u root -p{new-password} -h localhost password {new-password} mysqladmin -u root -p reloadClear the history file by typing history -c so that {new-password} isn't in plain text on the disk.
Apache
- cd /etc/apache2
- sudo vim httpd.conf
- Find #LoadModule php5_module libexec/apache2/libphp5.so and remove the leading #
- Find AllowOverride None within the <Directory "/Library/WebServer/Documents">section and change toAllowOverride All so that .htaccess files will work.
- Restart Apache: sudo apachectl restart
- Open Finder and navigate to /Library/WebServer/Documents/
- Create a new folder called "orig" and place all files currently in the Documents folder into it.
- Create a new file called info.php with <?php phpinfo(); inside it.
- Use Safari to navigate to http://localhost/info.php and check that the PHP version is displayed (5.3.0 at the time of writing).
php.ini
- cd /etc
- sudo cp php.ini.default php.ini
- sudo chmod ug+w php.ini
- sudo chgrp admin php.ini
- vim php.ini (assuming your user is a member of the admin group) and change settings appropriately. Change:
error_reporting = E_ALL | E_STRICT display_errors = On html_errors = On extension_dir = "/usr/lib/php/extensions/no-debug-non-zts-20090626"
(I like to see my xdebug errors in bright orange!)
Also, change all instances of /var/mysql/mysql.sock to /tmp/mysql.sock
Xdebug
Can't have a PHP development environment without xdebug!
- sudo pecl channel-update pecl.php.net
- sudo pear channel-update pear.php.net
- sudo pecl install xdebug
- Edit /etc/php.ini and add
zend_extension="/usr/lib/php/extensions/no-debug-non-zts-20090626/xdebug.so"
after the other extension lines.
- Restart apache: sudo apachectl restart and check in the phpinfo that xdebug is now loaded.
PHPUnit
- sudo pear channel-update pear.php.net
- sudo pear upgrade-all
- sudo pear channel-discover pear.phpunit.de
- sudo pear install phpunit/PHPUnit
It all works on this machine, anyway :)
Other options:


