Best way to call .NET classes from PHP?

末鹿安然 提交于 2019-12-05 11:15:05

Microsoft doesn't ship or support .NET on Linux. If you wan't to run .NET code on Linux then you should look at Mono. I don't know if PHP 5 supports Mono as well as MicroSoft.NET

NetPhp is a wrapper that works on top of the com_dotnet extension for PHP so you can call any .Net assembly in PHP even if it is not COM Visible and works with any version of the .Net framework.

https://github.com/david-garcia-garcia/netphp

Using .net classes and calling .net methods from Phalanger is very easy, since it's PHP compiler for .NET. You can check this article PHP for .NET: Introduction for .NET developers, the article is older(2007) so there can be few out-of-date examples, but the principles applies.

On Linux Phalanger runs fine on Mono, the biggest limitation here is that you can't use native extensions (from PHP distribution), which are supported only on Windows (the extension manager in Phalanger is built with C++/CLI which isn't supported on Mono). But still you can use some managed extensions for Phalanger that are available.

The Performance of the Phalanger in actual version(February 2011 release) is around 2times faster than PHP 5.3.5 via FastCGI.

I think the best way is to do it via COM.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!