PHP, Linux and the like…

October 12, 2007

PHP 5 under IIS: It’s ready.

Filed under: PHP, Win32 — Paul @ 4:31 am

One of my first blog posts, PHP Installation: A myriad of options asserted that Windows and PHP 4 in ISAPI mode was a frustrating affair. I hereby offer a partial retraction in this regard as PHP 5 is MUCH different.

The folks at PHP recently announced the retirement of the 4.x version slated for December 2007. After which PHP 4 will continue to receive critical updates until August 2008. If you still run PHP 4, now is the time to starting thinking about getting everything up to version 5.

With that in mind, we’ve decided to upgrade all our development environments to PHP 5. Our standard development machines aren’t really all that fancy; 2 year old Dell P4 H/T based desktops running XP. Being a small group of developers, we’re liberal with the choice of IDE; some use PHPEdit, while I’m drawn between Zend IDE and Eclipse.

Our previous run-ins with PHP4 in ISAPI mode were not good. While PHP would usually run to some extent, we were often faced with segfault error message at the top of the output and often IIS would space out. Yes, we’d followed the lengthy install read-me on the site and still could not get PHP and IIS to play nicely. We pretty much gave up on PHP in ISAPI under IIS and settled with PHP in CGI mode for development purposes.

With the introduction of PHP 5.2 and the impending retirement date; we took the plunge and downloaded the latest PHP 5.2.3 Windows Binary Installer package from PHP.net.

To begin, we un-installed the PHP 4.4.x series CGI installation and removed all traces of PHP from IIS. The PHP.ini file was also backed-up and removed. Once complete, IIS was restarted and we moved on to the installation.

This was straight-forward; it’s a familiar MSI package loaded with all the extensions and required libraries. We stepped through the installation selecting ISAPI mode and the extensions we need for our application such as LDAP, MB_string and MSSQL. For the sake of path simplicity, we also overrode the default “C:\Program Files\PHP…” path with a more friendly “C:\PHP5″ folder. The installer recommended that we “Reboot” because well… it IS Windows after all, and it’s your duty to rebootie…

Once back up, a simple “test.php” was called up containing nothing more than a simple <?phpinfo();?> . Unfortunately this didn’t work. The content was dumped literally, unparsed in the browser; the ISAPI filter obviously didn’t render. A quick look in IIS revealed that in fact the ISAPI filter was NOT configured under the Application Configuration property pages. A few clicks and key strokes linked .PHP files with “C:\PHP5\PHP5ISAPI.DLL”; restarted IIS.

Tried the test page again with success! The phpinfo() method called confirmed we were now in ISAPI Server API;

PHP 5.2.3 Win32 phpinfo() part

We now have a working PHP 5 ISAPI installation under Windows XP!

In terms of our application’s compatibility with PHP5; there are many occurrences of about 4 different issues.

  • mktime – called without setting a timezone
  • strtotime – called without setting a timezone
  • “Call-time pass-by-reference”
  • Assigning the return value of new by reference is deprecated.

The main architecture of our application works as designed and most of the issues were fixed with a blanket search/replace within the application. The timezone stuff is a bit of a nuisance as we’d designed a great set of wrappers in PHP 4 to handle timezone adjustments. PHP5 handling of this sort of thing is vastly improved, but the list of available timezones is quite large and needs to be integrated into our app.

I look forward to exploring the new reflection classes and tightening up the OO model of our application to take advantage of the new PHP 5 class features. Check out PHP’s migration notes for more detailed information on the differences and changes between PHP 4 and 5.

- Paul

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.