Rick Hurst Web Developer in Bristol, UK

Menu

zend framework and isapi rewrite on IIS (and why)

Recently I decided to standardise on php/zend framework for future ground-up development (where I have a choice/ influence). As some of you may have gathered, i’m a bit of a “jack of all trades” when it comes to web dev and I have a legacy of projects using different technologies. One of these is a sprawling classic ASP/ mysql app for a distribution company which is a (very successfully) working prototype of something I want to rebuild in a more generic, modular and industrial way, as a flagship product for Olivewood to develop and sell.

To be honest the classic asp works fine for most purposes, but is becoming increasingly obsolete, along with availability of developers, and I have been trying to move on from it for years. The obvious choice for migrating a classic ASP app would usually be ASP.NET, but frankly the idea of spending the rest of my working life tied into windows-only development, and the fighting with software licences and scarce availability (it seems, at least in this town) of contractors makes me want to give up try a different career altogether. So I decided on php a while back (mainly because I wanted something open source, with an abundance of developers – I think if you throw a coin randomly in the watershed in bristol, chances are you would hit a freelance php developer).

So with php decided on, I then spent time evaluating a few frameworks. They all look good – this was a difficult decision – but I decided on Zend because Olivewood will be primarily concerned with eCommerce and eProcurement, and with magento being built on zend, and the “big industry” partnerships, it seemed the right fit. It also seemed to be useful and provide structure without being overly prescriptive. Also by writing this here i’m hoping to commit myself to at least something!


So, I also wanted something that would work cross platform, even though the obvious choice is to run open source web apps on linux/ apache, it was important to me that it would also play nicely with IIS, as many businesses have already invested in windows servers and already run other apps on IIS and wouldn’t be happy supporting anything else. This gets an indignant response from many “purist” developers/ sysadmins, but i’m basing this on real-life situations, and I hate the idea of a potential client ruling out open source software because it won’t run on their IIS server.

The other factor here was that I wanted something that would coexist with my classic ASP app until such a time that I have rewritten everything I need to make it a pure zend framework/php app. The classic asp scripts will handshake with the php code by dumping session data to the database and passing credentials via a cookie, so the session data can be shared between the two. This is vital to the plan, as it is a long term project – and much of the investment in migrating this will be my own time and money.

Installing Apache on the same server and setting up some kind of proxying would be another option, but not on the live server that this app runs on. I also needed to prove that it would work on just IIS before betting my future business plans on it, even if the first thing I would do is suggest that it is run on Apache.

I wasted a monumental amount of time getting this working, although it turned out to be fairly trivial once I had cracked it. The red herring is that there are two versions of isapi rewrite – version 2 and version 3. All the zend related documentation I found (hardly any) seems to be for version 2 (although this wasn’t mentioned!), which I just couldn’t get to work at all for my setup, but eventually I gathered that version 3 has been almost completely rewritten to work with apache mod_rewrite rules. So now I have a classic asp app, with a single folder (caled “zend”) containing my front controller from where all the php will be served the application folder (with all the models, views, and controllers) is outside the site root.

My httpd.conf file looks like this:-

RewriteEngine on
RewriteBase /zend/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule !.(js|ico|gif|jpg|png|css|asp)$ /zend/index.php

Remember this is for version 3 of Isapi rewrite. All quite simple really, when you know how. It’s a pity it took me about 9 hours to work out how!

archived comments

Useful information, thanks!

My clients don’t allow ISAPI_Rewrite, so I’ve written a router that handles GET requests.

Regards,

Rob…

Rob… 2008-04-24 12:14:15

thank you i had the problem that I was using the wronth path to files, all I had to do was this no way

jenn 2008-05-31 15:01:45

Hey,
I cannot use ISAPi_Rewrite, what would be the alternative to run zend effectively on IIS 7.5 ?

Thank you.

Sam 2010-07-13 19:55:45