views:

660

answers:

2

By some coincidence this problem has come up twice in the last week.

A customer has an existing PHP web site which they want to keep. They also have or will soon have some ASP.net web pages that they wish to integrate into the existing site, in a way that it appears as a single site.

We have though of the following possibilities:

  • Use IFrame
  • Copy all html / menus to the new site and link between sites, user moves between sites but does not notice, if he does not look at the url
  • Use web services to read information from the asp.net web site and write the html on the PHP site.
  • Use WSRP (Web services Remote Portlets). Have tested this to display Sharepoint webparts on a Java site, have not tested with PHP.

Has anyone tried any of these? Has a better suggestion? Is there any we should definatly avoid?

Thanks

Shiraz

+1  A: 

Can the entire site be hosted on a windows machine running IIS? Because IIS can serve PHP pages as well as asp.net. That way you can mix-and-match the pages together, seamlessly.

Another, more "dirty" option would be to use PHP to "read" the HTML output from the remote asp.net pages directly. You would have one PHP file for each corresponding asp.net page and then you could "read" it via HTTP using PHP's file_get_contents method:

$content = file_get_contents('http://www.example.com/remotepage.aspx');

You'd probably want to cache the results locally to improve efficiency.

Dan Diplo
How do you deal with situations where remotepage.aspx requires values to be posted to it, viewstate, or multiple postbacks?
BrianLy
You couldn't! I would only suggest this for pages that didn't postback and were relatively "flat". Even then, I don't think it's a great idea, but it might work in an MVC site or for simple "read-only" content.
Dan Diplo
+2  A: 

It really depends on what an acceptable level of integration is. Your original suggestions have a number of issues with maintainability, and I would not suggest they are used for an public-facing internet site.

If I had full control, I might consider migrating the PHP site to IIS, and deploying ASP.NET pages to the site alongside the PHP files. This can be quite tricky depending on how the PHP site has been built. Problems you might run into including:

  • Use of mod_rewrite in the PHP app and whether you have a suitable replacement on Windows. This situation is a lot better at the time of writing but you might need to debug the existing configuration.
  • Extensions. Are all of the PHP libraries and extensions you need available on Windows?
  • Performance. Some people have reported unacceptable performance of PHP under Windows. I'm sure with the right performance tuning you can deliver something equivalent to your old site, if this is even an issue.

On your suggested options

  • Use IFrame. This is workable but a little clunky, It may turn out to be problematic if you need things like SSL or JavaScript interactivity between the code bases.
  • Link between sites. This is workable, but there could be issues if SEO is important to you. Sometimes there are more links than just menus that you need to consider too.
  • Use web services to read the ASP.NET pages. This is only really feasible if you have very simple pages that have zero interactions or postbacks. If you need to handle postbacks, viewstate etc you are going to be in trouble. Using ASP.NET MVC gives you more control and an easier experience integrating this way. My personal opinion is that it is extremely hacky and only something I would do for a single page (if it was really important).
  • Use WSRP (Web services Remote Portlets). I'm not sure that this is an option with regular ASP.NET, I always thought this was an additional feature with SharePoint.
BrianLy