What are the best options for connecting PHP apps to logic located in .NET libraries?
PHP, since v5.0, supports a DOTNET class that is supposed to let me invoke .NET logic from a PHP script. But it seems there are many problems - I've not been able to get it to work reliably, with arbitrary .NET classes. The doc is sort of slim and what is documented isn't really correct. The questions on the internets on this class are many, as are the bug reports on php.net.
I have been able to get PHP to connect with .NET via COM interop - but this requires that the .NET class be ComVisible. And as far as I know, because of the COM requirement, this works on Windows only.
I've heard of the Phalanger project but don't know many details. Does it work with arbitrary PHP scripts? Work on Linux? Does it have heavy perf or runtime implications?
Does it even make sense to do this, or is it one of those you-could-do-it-but-you-shouldn't sort of things?
EDIT: I'd like to hear about the general case: there is a wide variety of .NET class libraries available, and it would be nice to be able to take advantage of them from different environments, including PHP. Examples might be encryption, logging, data access, clients to HPC clusters. The particular immediate scenario is a ZIP library with AES encryption, available in .NET.
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.
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
I think the best way is to do it via COM.