views:

96

answers:

4

I'm working on an open source PHP project for websites, and once I release version 1.0, I want to provide the same product for websites using the IIS/ASP.NET platform.

When the time comes I'll go ahead and learn ASP.NET to do the translation, but it would be helpful for me to know already if there are any fundamental conceptual or architectural differences between the two platforms. I want to bear these in mind while building the PHP, to enable the two code bases to look as similar as possible, even though there will be of course be many differences in syntax and library function names.

I thinking of things like variable/array types, constant definitions, function namespaces, HTTP form and header handling. Anything that will make it difficult to look at the two code bases side-by-side, and see a direct correlation between each line of code.

My PHP is backwards compatible to 4.x, so I'm not using exception handling or objects.

Are there any good articles or point-by-points about this online?

A: 

Rather than try and do the translation to a language (and stack?) you're not familiar with I'd recommend looking at something like http://www.hawhaw.de/ to do the conversion/translation for you.

Matt Lacey
+1  A: 

Depending on which version of ASP.NET you are using, between PHP5 and .NET 3.5 there are incredible differences.

First, you will need to learn a .net language.

the .NET framework will take a lot of the work out of creating some interactive components, so people may expect that you are taking advantage of these, so the pages will either appear different, or you will need to do more work to get the php one to look like the asp.net.

I think the expectations of people will be the biggest hurdle in such an endeavor, and I agree with Matt Lacey that if there is a way to have it done for you you may just want to start with that, but, you will want to learn C# or VB.NET (I would suggest the former) and do the translation yourself, to better meet the expectations of your users.

Another big difference is that .NET provides several ways to create webservices, so you will need to decide which is best for your product when you write it.

But, if you have a good separation between the business logic and view part of your application then the design of the view shouldn't change too much.

James Black
+1  A: 

The differences bewteen PHP and classic ASP are relatively small, small enough that some mechanical translation is possible. take a look at asp2php which proves it can be done in the ASP to PHP direction.

However in the body of your question you mention asp.net. Typically ASP.NET uses a framework called webforms which is designed to make programming web applications much more like programming desktop applications. This is very different from the inline code favoured by raw PHP and in order to take advantage of ASP.NET you will have to pretty much abandon your php code and use the application only as a functional example of how the .NET port should work. I have heard that it is possible to write much more scripty style ASP.NET that writes the response directly but i have no experience of doing this and you will find support for it very minimal indeed.

In short: Porting raw PHP to classic ASP should be easy. Both are scripting languages which give raw access to various HTTP variables and parameters and allow the programmer to write directly to the response. If you are using a framework on the PHP or the ASP side, as you will be expected to if you use ASP.NET then things will be very different.

Jack Ryan
+1  A: 

Just to get it off my chest: Why convert it at all? Running the same codebase on an IIS/PHP stack should be fairly easy.

Having said that, take a look at the PHP to ASP.NET Migration Assistant tool Microsoft provides.

The page also provides a list of items that can be converted (well, mostly anyway):

  • Language migration
  • Built-in functions support
  • Include files
  • ...

As well as items that can't be converted (items you'll have to completely re-write):

  • Dynamic includes
  • Declare statement
  • PHP functions not completed in current script.
  • ...
Chris Pebble
looks and sounds cool.
thephpdeveloper