Note that there are some explanatory texts on larger screens.

plurals
  1. PORunning Quercus PHP inside Java
    primarykey
    data
    text
    <p>I am trying to run some PHP snippets from my Java application.</p> <p>I have seen this question: <a href="https://stackoverflow.com/questions/5298123/php-call-from-java-using-quercus">PHP Call from Java Using Quercus</a></p> <p>which suggests simply:</p> <pre><code>import com.caucho.quercus.QuercusEngine; QuercusEngine engine = new QuercusEngine(); engine.setOutputStream(System.out); engine.executeFile("src/test.php"); </code></pre> <p>and I have seen <a href="http://wiki.caucho.com/Quercus%3a_Command_Line_Interface_%28CLI%29" rel="nofollow noreferrer">http://wiki.caucho.com/Quercus%3a_Command_Line_Interface_%28CLI%29</a> which indicates:</p> <pre><code>QuercusEngine engine = new QuercusEngine(); engine.setIni("foo", "bar"); engine.execute("&lt;?php var_dump(ini_get('foo')); ?&gt;"); </code></pre> <p>But on doing that, I get:</p> <pre><code>Exception in thread "main" com.caucho.quercus.QuercusErrorException: eval::1: Fatal Error: 'var_dump' is an unknown function. at com.caucho.quercus.env.Env.error(Env.java:6559) at com.caucho.quercus.env.Env.error(Env.java:6445) at com.caucho.quercus.env.Env.error(Env.java:6109) at com.caucho.quercus.expr.CallExpr.evalImpl(CallExpr.java:198) at com.caucho.quercus.expr.CallExpr.eval(CallExpr.java:151) at com.caucho.quercus.expr.Expr.evalTop(Expr.java:523) at com.caucho.quercus.statement.ExprStatement.execute(ExprStatement.java:67) at com.caucho.quercus.program.QuercusProgram.execute(QuercusProgram.java:413) at com.caucho.quercus.QuercusEngine.execute(QuercusEngine.java:139) at com.caucho.quercus.QuercusEngine.execute(QuercusEngine.java:100) </code></pre> <p>I get the same thing for any function -- strlen, strcmp, phpinfo, etc.</p> <p>As described on <a href="http://quercus.caucho.com/" rel="nofollow noreferrer">http://quercus.caucho.com/</a> ...</p> <blockquote> <p>The Quercus .war file can be run on Java application servers such as Glassfish, i.e. it can be run outside of Resin. This .war file includes the Quercus interpreter and the PHP libraries.</p> </blockquote> <p>I have downloaded the war file from that page (<a href="http://caucho.com/download/quercus-4.0.25.war" rel="nofollow noreferrer">http://caucho.com/download/quercus-4.0.25.war</a>)</p> <p>and am running </p> <pre><code>$ javac -cp 'WEB-INF/lib/resin.jar;.' TestQuercus.java $ java -cp 'WEB-INF/lib/resin.jar;.' TestQuercus </code></pre> <p>the complete file is </p> <pre><code>import com.caucho.quercus.QuercusEngine; public class TestQuercus { public static void main(String[] args) throws Exception { QuercusEngine engine = new QuercusEngine(); engine.setIni("foo", "bar"); engine.execute("&lt;?php var_dump(ini_get('foo')); ?&gt;"); } } </code></pre> <p>I <em>am</em> able to do</p> <pre><code>java -cp 'WEB-INF/lib/resin.jar' com.caucho.quercus.CliQuercus foo.php </code></pre> <p>where foo.php includes <code>&lt;?php phpinfo; ?&gt;</code></p> <p>So how can I get from there to a working QuercusEngine?</p> <p>Thanks, </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload