getAttribute( "php.java.bridge.JavaBridge", 100); $config = $ctx->getAttribute ( "php.java.servlet.ServletConfig", 100); $context = $ctx->getAttribute( "php.java.servlet.ServletContext", 100); $servlet = $ctx->getAttribute( "php.java.servlet.Servlet", 100); ?>
The PHP/Java Bridge web application contains two servlets. The PhpJavaServlet
handles requests from remote PHP scripts running in Apache/IIS or from the command line.
The second servlet PhpCGIServlet
can handle requests from internet clients directly.
The following shows the settings of the PhpJavaServlet
and the PhpCGIServlet
.
The PhpJavaServlet
handles requests from PHP clients.
Apache/IIS/console::PHP <--> PhpJavaServlet
It listens for PHP/Java Bridge protocol requests on the local interface or on all available network interfaces and invokes Java methods or procedures. The following example accesses the bridge listening on the local interface:
<?php
require_once("http://localhost:8080/JavaBridge/java/Java.inc");
$System = java("java.lang.System");
echo $System->getProperties();
?>
Option | Value | Description |
---|---|---|
servlet_log_level | getlogLevel());?> | The request log level. |
The PhpCGIServlet
runs PHP scripts within the J2EE/Servlet engine.
internet browser <--> PhpCGIServlet <--> php-cgi <--> PhpJavaServlet
It starts a PHP FastCGI server, if possible and necessary. Requests for PHP scripts are delegated to the FastCGI server. If the PHP code contains Java calls, the PHP/Java Bridge protocol requests are delegated back to the current VM, to an instance of the PhpJavaServlet
.
Option | Value | Description |
---|---|---|
php_exec | getInitParameter("php_exec")); echo $val?$val:"php-cgi"?> | The name and location of your system_php_exec. For example /opt/PHP/bin/php-cgi . Default is /usr/bin/php-cgi or c:/Program Files/PHP/php-cgi.exe or a php-cgi from the PATH. |
prefer_system_php_exec | getInitParameter("prefer_system_php_exec")); echo $val?$val:"Off"?> | Ignore a local WEB-INF/cgi/php-cgi-ARCH-OS executable from the web archive and use the specified php_exec . Default is Off. |
php_include_java | getInitParameter("php_include_java")); echo $val?$val:"Off"?> | Shall the server add <?php include_once("java/Java.inc");?> at the top of each PHP script? Default is Off. |