views:

419

answers:

4

We've got a large classic asp application and we consider migrating to either asp.net or php. I don't want to talk about the pros and cons of either one, but I'd rather like to know whether there are ways to avoid a complete rewrite in one shot when migrating to php. We simply can't stop maintaining the current codebase just to do a rewrite. So things have to go hand in hand.

If we'd move to asp.net, we should be able share session data among both technologies and have parts of the site replaced with new asp.net code, while other just keep on running. Is such an approach possible with php? Does anyone has got experiences with such a migration or could point me to some good readings?

+1  A: 

Yes; it is possible to share session data between ASP and ASP.NET pages on a single web application. We do that with our legacy code at my work.

I know it's possible to run PHP on the IIS. Not sure about sharing sessions between ASP and PHP scripts though.

roosteronacid
+2  A: 

The ability to share session state between ASP Classic and ASP.NET isn't an intrinsic feature of either language, though it's fairly easy to accomplish.

Microsoft provides sample code: http://www.google.com/search?client=safari&rls=en-us&q=share%20session%20data%20between%20ASP%20and%20ASP.NET%20pages&ie=UTF-8&oe=UTF-8

By using Microsoft's example, you could pretty easily implement something similar in PHP. Basically you'd use the ASP Classic portion of Microsoft's code above. Then in PHP you'd write a fairly simple class to read session state from the database into an array or collection when each page is loaded. It's a little extra work in PHP, but shouldn't be more than a few extra days of coding and testing.

PHP runs pretty well on IIS6 in my limited experience and support for it is supposedly even better in IIS7. The only snag I've hit in is that a most of the PHP code out there assumes you're running on Linux/Unix... but generally this is only an issue for file-handling code (think: user image uploads) that works with local filesystem paths. Because they assume your filesystem uses / instead of \ like on Windows. Obviously fairly trivial to fix.

Good luck!

John Booty
very helpful answer. thanks a lot.
Matthias
A: 

Just another option. John Booty has a good suggestion too.

If the session data isn't sensitive information you can work cookies which will also be platform agnostic pending the user has cookies turned on.

That's probably not your best option given the post but another to think about.

jerebear
this is actually not an option for us. but thanks for the answer anyway.
Matthias
+1  A: 

"I'd rather like to know whether there are ways to avoid a complete rewrite in one shot when migrating to php"

Welcome to our world.

Our FogBugz codebase was written in classic ASP and when we wanted to offer it on Linux, the simplest solution was to write a compiler which read the asp and emitted php. It wasn't that difficult, and didn't take more than a few weeks.

The upside was when we decided to switch our entire application to .NET it only meant tweaking the compiler a bit to output .Net object code.

But to get back to your answer, ASP and PHP are VERY VERY similar and depending on your app there are really naive translators that might get you most of the way there.

Michael Pryor
that sounds like an interesting idea. btw, have you been talking somewhere else about the compiler or is this all company secret? I'd love to read more about that.
Matthias
It's not a secret, but it's also not a shipping product. It's too specific for our app to be generally useful to anyone else.
Michael Pryor