PDA

View Full Version : Call PHP Class From Java


nirajsalot
03-15-2011, 05:47 AM
Hi,

We have PHP application , which is already developed and running on Apache.

Now we are writing new application which is written in Java. Now we would like to reuse the login which is already there in PHP.

We have decided to go with Quercus for doing this Integration.

PHP runs on Apache
and J2EE application Runs on Weblogic.

Now for example we have below mentioned PHP class running on Apache.

<?php
class Person {
var $name;

function gettest()
{
return "Welcome1";
}

}
?>

How can I call this class & method gettest() from Java application which is running on Weblogic.

Kindly help me with a sample code for doing this.

Thanks.

andolasoft
03-27-2012, 06:09 AM
I am writing a java class.And i have some logic in test.php One of the methods of that java class should invoke test.php so that test.php performs some computation and returns the result to the invoking java method. Can i do that with

runtime rt = runtime.getRuntime(); process exec = rt.exec(test.php);

Please suggest. Thanks in advance.

nam
03-30-2012, 05:08 PM
Hi,

There are various ways to call PHP from Java. One way is to use:

Value com.caucho.quercus.QuercusEngine.executeFile(Strin g path)