dongxing4643 2012-10-11 17:49
浏览 40
已采纳

用于.net的Phalanger和php库

I have three php classes Im trying to use in my .net application. I used Phalanger to take those three classes and make a .dll file using this command:

phpc /target:dll Client.php Crypt.php Exception.php

Which of course outputted Client.dll as well as a Client.pdb files.

From there I went to VS2012 and created a new asp.net application and added the Client.dll as a reference. However I do not see the public methods from any of the classes and the object browser window shows:

Client>Client>Base Types>Object (so that I only have the methods of type Object)

I have tried this method/tutorial to get it to work which involves casting a custom interface onto your object however I get the error:

the type or namespace name ScriptContext could not be found

Which of course means that it doesnt know what or where ScriptContext. However this tutorial is from 2007 so I dont know if its just to far out of date or where I should get that class from?

The other tutorial I found is just as old. It says:

If you want to use existing PHP source (developed for standard interpreter) without modifications you have to use legacy mode, but when you want to develop new PHP project you can consider using pure mode

But I cannot find the step for legacy mode within the document and would prefer that over trying the "pure" mode (so that I dont have to change/edit my existing php code). I did try (pure mode) however it wouldn't compile (phalanger compile) with the command above (adding the DynamicObject.php class to the command).

How can I get to my public methods within the php class?

  • 写回答

1条回答 默认 最新

  • dongxia2030 2012-10-12 15:39
    关注
    phpc /target:dll Client.php Crypt.php Exception.php
    

    creates DLL in legacy (standard) mode. This DLL contains 'weird' namespaces, needed for compatibility with PHP semantics. (these namespaces separate code from different script files). .NET interoperability overview of Phalanger 3.0 blog post describes how to use scripts compiled in standard mode.

    Command line option /pure+ tells compiler to create so-called pure mode assembly. In this mode, compiler concatenates all the source files and compiles them as one (as C# does), without any weird namespaces. If you specify [\Export] attribute above the PHP class declaration, resulting DLL will look as it would be compiled from C# code, and you will be able to reference it and use its classes normally.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料