PHP Developer's Snow Leopard Upgrade Notes
I'm upgrading to Snow Leopard, and I intend to switch from MAMP to the built-in PHP/Apache 2 configuration. As a PHP developer, there are several notable things that I wanted to track as I performed my upgrades. This article tracks those changes
My current OS 10.5 toolchain for PHP was this:
- PHP 5.2.6 (MAMP)
- Apache 2 (MAMP)
- MySQL 5 (MAMP)
- Several PEAR packages installed into MAMP's PHP 5, including PHPUnit, PhpDocumentor, Phing, and XDebug
One of the desired outcomes was to switch to the OS X version of PHP and Apache, which is tenable now that PHP is more robust (and now that I know how to use PEAR with the OS X version). It's also desirable because Snow Leopard is now running PHP 5.3. Here are my notes on the upgrade.
Update: Problems with PHPUnit and Phing. <!--break-->
I will keep this updated as I work on updates.
- After running the update...
- TextMate is running fine
- After re-adjusting my $PATH var, I can indeed see that the new version of PHP is 5.3.0. All of the extensions I really want (full GD, XML, Phar, SQLite, PDO and SPL) are supported.
- Git was mysteriously missing
I had to re-install Git.
PEAR and PECL Packages
NOTE: You may want to upgrade PEAR before doing anything else:
$ sudo pear upgrade pear
My pear version went from 1.8.0 to 1.9.0.
PhpDocumentor installed with no problems, using the command:
sudo pear install PhpDocumentor
XDebug installed with no problems using the command:
$ sudo pecl install xdebug
For details on how I configured it to work on my system, read Installing XDebug 2 on Mac OS 10.6 Snow Leopard (with PHP 5.3).
PHPUnit installed with no problems using:
$ sudo pear channel-discover pear.phpunit.de $ sudo pear install --alldeps phpunit/PHPUnit
As far as I can tell, the
--alldeps argument is required.
Phing installed with no problems using:
$ sudo pear channel-discover pear.phing.info $ sudo pear install phing/phing
Binaries are installed into
To test out how Apache and PHP are working, I wrote short script and placed int in
<?php phpinfo(); ?>
This simply executes
phpinfo() and prints out the details of PHP. It produced the expected output (see the screenshot above). Looking through the configuration details was like a trip to the candy store.
One interesting feature I noticed was mysqlnd support. What is this? According to the official MySQL site: The MySQL native driver for PHP is an additional, alternative way to connect from PHP 5.3 or newer to the MySQL Server 4.1 or newer. It is a replacement for the libmysql, the MySQL Client Library. As of PHP 5.3 you can use ext/mysql, ext/mysqli and PDO_MYSQL either together with libmysql as you did in the past or with mysqlnd.
Apparently, along with resolving licensing issues, the native driver improves performance. In Snow Leopard, PDO uses this by default, it appears. I am looking forward to seeing this new driver in action.
Also along with the many other new features, Snow Leopard's PHP build contains support for the following stream wrappers:
https, ftps, compress.zlib, compress.bzip2, php, file, glob, data, http, ftp, phar. Support for compressed files is a nice extra. Support for phar is one of the main reasons I'm drooling over PHP 5.3.
Testing the PHP 5.3 CLI and Packages
Earlier, I explained how I upgraded several PEAR and PECL packages. How did I test them? By building QueryPath from the command line (and running tests). Since QueryPath uses xdebug to run performance tests, PHPUnit to run unit tests, PhpDocumentor to build documentation, and Phing to do all the grunt work, it seemed to me to be a great way of exercising the new tools.
After adjusting some paths, QueryPath's Quasar branch seems to be building and testing fine.
Update: I have found a problem with PHPUnit 3.4 and Phing. PHPUnit refactored part of their formatting code in a way that breaks Phing. In a nutshell, they renamed XML.php to JUnit.php and changed some function names. Here's the issue: http://phing.info/trac/changeset/592
To fix this, you can download phing-fix.zip (at the bottom of this entry), unzip it, and copy
/usr/lib/php/phing/tasks/ext/phpunit/phpunit3. Note that you need to have root permissions to copy.
Still to Come
I have been testing PHP from the command line, but have not yet tested the webserver version, nor have I tested Apache yet. If those go well, I am going to attempt the following:
- Test the following PEAR packages:
- Install CouchDB or MongoDB
- Install MySQL from source
The Big Problem: Drupal
The one problem that I don't think I can fix in the near term is the fact that Drupal will not run on PHP 5.3. I believe core is now working, but Views is not, and Drupal's of marginal use without views.