0

I try to get a PHP ScriptEngine from the ScriptEngineManager, but getEngineByName("php") returns null. The following unit test works, if I replace "php" with "javascript", but it fails for "php".

import static org.junit.Assert.*;
import org.junit.Test;
import javax.script.*;

public class ScriptEngineTest {
    @Test
    public void executeCommand() throws Exception {
        ScriptEngine engine = new ScriptEngineManager().getEngineByName("php");
        assertNotNull(engine);
    }
}

I must be missing something obvious. I know, that Rhino comes with Java 6 and is behind the javascript engine. Where do I get this for PHP?

EDIT:

I made my first step forward. Hereis a download link for JavaBridgeTemplate5442.war. I unzipped this war file. Under WEB-INF/lib/ I found the jar files

  • JavaBridge.jar
  • php-script.jar
  • php-servlet.jar

When I put JavaBridge.jar in my class path, the unit test works. (Probably I will also need php-script.jar to actually execute PHP code.)

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
GrGr
  • 4,098
  • 5
  • 21
  • 20

1 Answers1

1

Scripting engines available under JSR 223 are listed here (bottom of the page).

Current implementations of PHP include Quercus and PHP to Java bridge.

ChssPly76
  • 99,456
  • 24
  • 206
  • 195
  • I saw both before, but for Quercus still I do not see, how I can integrate it. I finally made it with php-java-bridge. I will edit my question. – GrGr Aug 02 '09 at 22:19
  • Look here: http://groovy-news.org/e/page/axelclk?entry=experiments_with_the_jsr_223 and here: http://weblogs.java.net/blog/ludo/archive/2007/03/100_java_quercu.html I haven't tried Quercus myself, though. – ChssPly76 Aug 02 '09 at 22:26
  • Thanks, looks similar to the solution I found for php-java-bridge. I think, that this packaging makes it a little harder to actually use these bridges. – GrGr Aug 02 '09 at 22:33