对于.NET Phalanger和PHP库 [英] Phalanger and php library for .net

查看:131
本文介绍了对于.NET Phalanger和PHP库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有三个PHP类我试着在我的.NET应用程序中使用。我用Phalanger拿这三个类,并使用此命令使一个.dll文件:

  phpc /目标:DLL Client.php Crypt.php Exception.php
 

这当然输出Client.dll以及一个Client.pdb文件

从那里,我去了VS2012并创建了一个新的asp.net应用程序,并增加了Client.dll作为参考。不过,我没有看到公共方法从任何类和对象浏览器窗口显示的:

  

客户端>客户端>基本类型>对象(所以我只有方法   Object类型)

我已经试过方法/教程,以得到它的工作涉及铸造一个自定义界面上你的对象,但是我得到的错误:

  

的类型或命名空间名称ScriptContext中找不到

这当然意味着它不知道什么或在ScriptContext中。但是本教程为2007年,所以我不知道,如果它只是远远过时或者我应该得到这个类的?

的<一个href="http://www.$c$cproject.com/Articles/17311/Phalanger-PHP-for-NET-Introduction-for-NET-develop#5_1"相对=nofollow>其他教程我发现是一样老。它说:

  

如果您希望使用现有的PHP源(制定标准   除preTER)无需进行修改,你必须使用传统模式,但   当你想开发新的PHP项目,你可以考虑使用纯   模式

但我不能找到文档中的传统模式的一步,将preFER,超过尝试纯模式(让我没有改变/编辑我现有的PHP code)。我曾尝试(纯模式),但它不会编译(phalanger编译)以上(加上DynamicObject.php类的命令)命令。

我怎样才能到我的PHP类中的公共方法?

解决方案

  phpc /目标:DLL Client.php Crypt.php Exception.php
 

创建DLL的传统(标准)模式。这个DLL中包含怪异的命名空间,需要用PHP语义兼容性。 (这些命名空间分开从不同的脚本文件code)。 .NET Phalanger 3.0 <互操作性概要/一>博客文章介绍了如何使用在标准模式下编译脚本。

命令行选项 /纯净+ 告诉编译器创建所谓的纯模式汇编。在这种模式下,编译器将所有的源文件和编译它们作为一个(如C#一样),没有任何奇怪的命名空间。如果指定 [\导出] 属性上面的PHP类声明,结果DLL会看,因为它会从C#code编译,你将能够引用它与通常使用它的类。

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?

解决方案

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.

这篇关于对于.NET Phalanger和PHP库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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