Skip to content

belgattitude/php-java-bridge

Repository files navigation

PHP Java bridge

Build Status Maven Central License (develop branch: Build Status)

The soluble PHPJavaBridge server fork allows PHP/JVM interoperability through a local network protocol between both runtimes.

Disclaimer: Unofficial fork !!!

This fork was initially made on the sourceforge version made by Jost Boekemeier as its development seemed to have stopped after version 6.2.1.

Be aware that since the project have been forked, the official repo looks to be alive again with recent versions supporting PHP7. Unfortunately most of the the fixes and enhancements made on this fork have not been merged in upstream version.

Feel free to choose which version you install (fork or official). To keep a track of differences, you can refer to the fork status page.

Note that this fork have been specifically designed for PHP -> Java integration, so so if you intend to use it from Java -> PHP, the best is to use the official version as it looks better tested for that scenario.

Installation

This repository can be used to develop, test and and build the JavaBridge server.

Be sure to consult the soluble-japha website where you'll find more information relative to php/java integration.

Documentation

Older documentation can be found in the PHP/Java bridge site

Releases

  • You can download pre-compiled java bridge binaries on the releases page (jdk8).

  • Major releases are published on Maven central.

    With maven:

    <dependency>
       <groupId>io.soluble.pjb</groupId>
        <artifactId>php-java-bridge</artifactId>
       <version>x.y.z</version>
    </dependency>
    

    or gradle

    compile 'io.soluble.pjb:php-java-bridge:x.y.z'
    

To register the PHPJavaServlet, you can have a look to the example web.xml file.

Build the project

Requirements

  • Oracle JDK 7,8
  • Optionally ant for old Java.inc generation

Get the sources

You can either clone the project with:

$ git clone https://github.com/belgattitude/php-java-bridge.git

or download a zip tarball from the github page.

Gradle build

Build the project with the provided gradle wrapper:

$ cd php-java-bridge
$ ./gradlew build 

The generated files are available in the /build/libs folder:

File Description
php-java-bridge-<VERSION>.jar JavaBridge library (servlet and standalone).
php-java-bridge-<VERSION>-sources.jar Source code.
php-java-bridge-<VERSION>-javadoc.jar Generated api doc.

Additionally a generic template file is automatically generated:

File Description
JavaBridgeTemplate.war A ready to deploy war example file.

Adding deps to the builded '.war'

Instead of modifying directly the main build.gradle file, you should consider using init-scripts. Examples can be found on the init-scripts doc.

Usage

Currently only tested on Tomcat 7/8, should be running on any servlet 2.5 compatible container.

Servlet registration

You can have a look to the web.xml default configuration for the servlet configuration settings.

Deploy

Ensure you have a Tomcat server installed.

And copy the ready to run JavaBridgeTemplate.war in the tomcat webapps folder:

$ sudo cp ./build/libs/JavaBridgeTemplate.war /var/lib/tomcat8/webapps/JavaBridgeTemplate.war

Wait few seconds for deployment and point your browser to http://localhost:8080/JavaBridgeTemplate, you should see the bridge landing page :

Have a look to the error log if needed:

$ cat /var/log/tomcat8/catalina.out

Develop

For development, the use of the ./gradlew tomcatRun and ./gradlew tomcatStop allows testing without the need of deployment.

Dependencies can be added in the build.gradle file.

FAQ

OutOfMemory errors under Tomcat

If you get OutOfMemory errors, you can increase the java heap tomcat:

$ sudo vi /etc/default/tomcat8

Look for the Xmx default at 128m and increase

JAVA_OPTS="-Djava.awt.headless=true -Xmx512m -XX:+UseConcMarkSweepGC"

and restart

$ sudo service tomcat8 restart

Contribute

Feel free to fork and submit pull requests :)

Credits

Original developers:

  • Jost Boekemeier
  • Andre Felipe Machado,
  • Sam Ruby,
  • Kai Londenberg,
  • Nandika Jayawardana,
  • Sanka Samaranayake,

Forked version

See the CREDITS.md for an up to date of list of contributors.