[英]Best way to integrate PHP with asp.net / asp.net-mvc
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. 客户拥有要保留的现有PHP网站。 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.
他们还拥有或即将拥有一些ASP.net网页,希望将它们集成到现有站点中,以使其显示为单个站点。
We have though of the following possibilities: 但是,我们有以下几种可能性:
Has anyone tried any of these? 有人尝试过这些吗? Has a better suggestion?
有更好的建议吗? Is there any we should definatly avoid?
有什么我们应该绝对避免的吗?
Thanks 谢谢
Shiraz 西拉
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. 如果可以完全控制,我可能会考虑将PHP网站迁移到IIS,并将ASP.NET页面与PHP文件一起部署到该网站。 This can be quite tricky depending on how the PHP site has been built.
根据PHP网站的构建方式,这可能非常棘手。 Problems you might run into including:
您可能会遇到的问题包括:
On your suggested options 在您建议的选项上
All these options are completely overboard! 所有这些选择都太过分了!
Simple solution would be to keep the solutions hosted seperately, Apache & IIS respectively. 一个简单的解决方案是将解决方案分别托管在Apache和IIS中。 And handle the integration Via Routing.
并通过路由处理集成。 The authentication could be handled by using the "Cookie"
可以使用“ Cookie”来处理身份验证
We've handled this recently for a customer with no issues 我们最近为没有问题的客户处理了此问题
The web front end was based on wordpress & mySQL and an entire reporting module was MVC 3/4 based on SQL server 2008 r2 based. Web前端基于wordpress和mySQL,整个报告模块是基于SQL Server 2008 r2的MVC 3/4。
We just used sub domains .ie www.somecompany.com for website and reports.somecompany.com for the reports. 我们仅将子域名.ie www.somecompany.com用于网站,将reports.somecompany.com用于报告。
We then just wrote a simple wordpress extension, to store linking data to which contained relevant information to create reports. 然后,我们只是编写了一个简单的wordpress扩展名,用于存储包含相关信息的链接数据以创建报告。 ie Guid ID of user and report type etc.
即用户的Guid ID和报告类型等。
Which essentially just presented the User with a page containing some reports options they could run - hyperlinks <a href="http://reports.somecompanyurl.com/bill/{some guid}>You Monthly Bill</a>
实际上,这实际上只是向用户显示了一个页面,其中包含一些可以运行的报告选项-超链接
<a href="http://reports.somecompanyurl.com/bill/{some guid}>You Monthly Bill</a>
ie Monthly Bill 即每月帐单
Both sites shared a common theme, which does carry some maintenance burden, but no more than a usual web project. 这两个站点共享一个共同的主题,这确实带来了一定的维护负担,但是只不过是一个普通的Web项目而已。 ie.. MVC and PHP theme files do have some differences, but in general the CSS files were the same.
即.. MVC和PHP主题文件确实有一些区别,但是通常CSS文件是相同的。
I think we did customize the cookie a bit, but this wasn't really any hardship, as both solutions just used the same cookie name and cookie encryption. 我认为我们确实对cookie进行了一些自定义,但这并不是什么难事,因为两种解决方案都使用相同的cookie名称和cookie加密。
On the whole it was a fairly painless integration project, as most communication was handled via routing. 总体而言,这是一个相当轻松的集成项目,因为大多数通信都是通过路由进行的。
we've been running this for 6 months without any issues. 我们已经运行了6个月,没有任何问题。
Can the entire site be hosted on a windows machine running IIS? 可以将整个站点托管在运行IIS的Windows计算机上吗? Because IIS can serve PHP pages as well as asp.net.
因为IIS可以提供PHP页面以及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. 另一个更“肮脏”的选择是使用PHP直接从远程asp.net页“读取” HTML输出。 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: 每个对应的asp.net页都有一个PHP文件,然后可以使用PHP的
file_get_contents
方法通过HTTP“读取”它:
$content = file_get_contents('http://www.example.com/remotepage.aspx');
You'd probably want to cache the results locally to improve efficiency. 您可能希望将结果缓存在本地以提高效率。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.