从PHP调用.NET类的最佳方法? [英] Best way to call .NET classes from PHP?

查看:204
本文介绍了从PHP调用.NET类的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

PHP应用程序与.NET库中的逻辑连接的最佳选择是什么?



PHP从v5.0开始支持 DOTNET类,它应该允许我从PHP脚本调用.NET逻辑。但是它似乎有很多问题 - 我不能得到它可靠,工作任意.NET类。文档是一种苗条,并且 文档是不是真的正确。关于这个类的互联网上的问题很多,以及php.net上的错误报告。



我已经能够通过COM interop获得PHP与.NET的连接 - 但这需要.NET类是ComVisible。据我所知,由于COM要求,这只在Windows上工作。



我听说过 Phalanger项目但不知道很多细节。它可以与任意PHP脚本工作吗?在Linux上工作?它具有重型perf还是运行时间的影响?



这样做是否有意义,或者是那些你可以做的,但是你不应该有什么东西? / p>

编辑:我想听听一般的情况:有各种各样的.NET类库可用,这将是很好的能够利用的他们来自不同的环境,包括PHP。示例可能是加密,日志记录,数据访问,客户端到HPC集群。特别直接的情况是具有AES加密的ZIP库,可在.NET中使用。

解决方案

我认为最好的方法是通过COM。


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.

解决方案

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

这篇关于从PHP调用.NET类的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆