如何使用 Java/ASP.NEt/Python 编写代码以使用 PHP 编写的基于组件的库?
我有一个基于组件的库,它完全用 PHP 编写,并且工作起来很有魅力。
代码示例片段如下:
<?php
require_once 'lib/my_class_file.php';
$variable1 = "some-value";
$variable2 = "some-value";
$new_variable = ClassName::newInstance(.....);
$new_variable->method_call($args);
?>
现在,我想将该库的使用扩展到其他平台,例如 Java、ASP.NET 和 Python。我不知道如何在 Java、ASP.NET 和 Python 等其他语言中使用这个库。
我关心的是这是否可能。如果可能的话,任何指针/在线教程/示例代码将不胜感激。
提前致谢。
I have a component based library which is completely written in PHP and works like a charm.
A sample snippet of the code is :
<?php
require_once 'lib/my_class_file.php';
$variable1 = "some-value";
$variable2 = "some-value";
$new_variable = ClassName::newInstance(.....);
$new_variable->method_call($args);
?>
Now, I want to extend the use of this library to other platforms like Java, ASP.NET and Python. I don't know how can I consume this library in other languages like Java, ASP.NET and Python.
My concern is whether this is possible or not. If possible any pointer / online tutorials / sample code would be highly appreciated.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
Web 服务将是您问题的常见答案。过去 SOAP 很流行 - 您仍然可以使用它,但使用简单的 REST 服务器,或者更好的是,使用 Thrift 作为通用的可扩展解决方案。要使用它,您首先需要使用定义文件描述参数和返回值的数据结构,然后运行一个脚本,为您将使用的各种编程语言创建服务器和客户端。
另请参阅 https://github.com/volca/thrift 了解 php 服务器的非阻塞端口(我自己没有测试过)
A web service will be the common answer for your problem. In the past SOAP was popular - you can still use it, but it's probably better to use a simple REST server, or even better, use Thrift as a generic scalable solution. To use it, you first need to describe your data structures for your parameters and return value using a definition file, and then run a script which creates servers and clients for the various programming languages you will use.
See also https://github.com/volca/thrift for a non-blocking port of the php server (I did not test it myself)