tags:

views:

449

answers:

3

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.

+1  A: 

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

Jonathan Parker
I know about Mono. But I don't know if PHP+Mono works or makes sense.
Cheeso
A: 

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

Cheeso
A: 

I'm looking into this myself. A quick and dirty method may be to wrap a .Net class in an executable and have php call the executable (presumably using arguments, text files or similar to communicate).

Does anyone have experience doing this??

Phil