1

I'm building a Java based HTTP Server with a plugin system. And I'm trying to find a simple and elegant way to load PHP as a Template Engine plugin. preferably something that also requires very steps for users that install the plugin, for example pointing to the php directory and the plugin does the rest. However, Google is not proving to be very helpful (it doesn't matter what keywords I use the results are rather useless).

I've found several things about a java-php-bridge, which seems like it could work but it's a rather large old (java 1.4 support) library and I've got a feeling that there is a simpler dedicated solution.

I want to be able to push a map with variables to PHP (headers, get vars, custom vars, etc.) and retrieve the parsed PHP back (including headers that have been set and other possible output)

and, if possible, I want to do this with the least possible computing time (e.g. I could call php.exe every time, but if I'm correct that's a rather expensive way to handle it)

2
  • 1
    I have no idea wat it does exactly, mut you might take a look at quercus.caucho.com, a PHP compiler for the JVM Commented Nov 16, 2014 at 10:12
  • @jeroen_de_schutter it's close, but not exactly. This is a specific implementation, I would prefer a standalone library you can just feed php files from your own java code. But thanks for the tip! I didn't know this existed. Commented Nov 19, 2014 at 21:21

1 Answer 1

1

If you want to interact with PHP in web manner (header, request variables and so on), you can use:

  1. CGI mode (slow and not effective, but rather simple).
  2. FastCGI mode (fast and effective, but requires separated FastCGI server to be running).
  3. SAPI (rather fast and effective, but requires separated SAPI server to be running).

You can search for a client Java code to interact with PHP one of this ways. It solution will not be found, you can write you own client part. Fast and effective solution newer will be simple to programmer and end user.

Using C/C++ php engine can be used as library and linked in application (like mod_php in Apache httpd). This is the fastest way. But it's not possible with Java.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.