1

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.

Mahendra Liya
  • 12,912
  • 14
  • 88
  • 114
  • 1
    What do you mean by "consume?" Do you want to be able to make HTTP requests to a server running that PHP code? That's about as much interop as you're going to get without jumping through some serious hoops. – Matt Ball Jun 09 '11 at 16:07
  • 1
    @Matt: Yes may be something like that... Honestly I don't know what would be the correct word to use.. but i want this code to be used in JSP/Server / Asp.net / python... Any idea as to how can I do it.. any kind of pointers/online tutorial/sample code..? – Mahendra Liya Jun 09 '11 at 16:17

1 Answers1

1

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)

Udi
  • 29,222
  • 9
  • 96
  • 129