2017 © Pedro PelĂĄez
 

library japha-pjb62-compat

Soluble PHP Java bridge PJB62 compatibility layer

image

soluble/japha-pjb62-compat

Soluble PHP Java bridge PJB62 compatibility layer

  • Wednesday, March 1, 2017
  • by belgattitude
  • Repository
  • 1 Watchers
  • 0 Stars
  • 23 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 5 % Grown

The README.md

soluble-japha-pjb62-compat

PHP Version Build Status Code Coverage Scrutinizer Code Quality Latest Stable Version Total Downloads License, (*1)

Introduction

*** Work in progress ***, (*2)

Historically the PHP/Java bridge client didn't support namespaces., (*3)

Install this package if you have existing code relying on legacy php-java-bridge and don't want to refactor to the newer implementation provided by soluble/japha., (*4)

Features

  • Make soluble-japha compatible with the procedural phpjavabridge legacy api

Requirements

Installation

  1. PHP installation (client), (*5)

    Through composer., (*6)

    $ composer require "soluble/japha-pjb62-compat"
    

    Most modern frameworks will include Composer out of the box, but ensure the following file is included:, (*7)

    <?php
    // include the Composer autoloader
    require 'vendor/autoload.php';
    
  2. PHP-Java-bridge server, (*8)

    Refer to the latest documentation provided in the soluble-japha project., (*9)

    Or as quick install guide use the standalone server :, (*10)

    $ mkdir -p /my/path/pjbserver-tools
    $ cd /my/path/pjbserver-tools
    $ composer create-project --no-dev --prefer-dist "belgattitude/pjbserver-tools"
    $ ./bin/pjbserver-tools pjbserver:start -vvv ./config/pjbserver.config.php.dist
    

    The server will start on default port 8089. If you like to change it, create a local copy of ./config/pjbserver.config.php.dist and refer it in the above command., (*11)

    Use the commands pjbserver:stop, pjbserver:restart, pjbserver:status to control or query the server status., (*12)

    For production the recommended way is to deploy the JavaBridge servlet into a J2EE compatible server (Tomcat,...). Have a look to the complete java server installation documentation., (*13)

Examples

Connection example

Configure your bridge adapter with the correct driver (currently only Pjb62 is supported) and the PHP-Java-bridge server address., (*14)

<?php

use Soluble\Japha\Bridge\Adapter as BridgeAdapter;

$ba = new BridgeAdapter([
    'driver' => 'Pjb62',
    'servlet_address' => 'localhost:8089/servlet.phpjavabridge'
]);

This replace the include('xxx/Java.inc) used in previous versions., (*15)

Basic Java usage

With legacy mode enabled you can use the java* function directly, (*16)

<?php

use Soluble\Japha\Bridge\Adapter as BridgeAdapter;

$ba = new BridgeAdapter([
    'driver' => 'Pjb62',
    'servlet_address' => 'localhost:8083/servlet.phpjavabridge'
]);

$bigint = new Java("java.math.BigInteger", 1);
$system = java_class('java.lang.System);

java_instanceof($bigint, 'java.math.BigInteger'); // -> true
java_inspect($bigint); 
java_values($bigint);
//java_invoke();

API

Refactor constants

Constant Example
JAVA_HOSTS define("JAVA_HOSTS", "127.0.0.1:8787")
JAVA_SERVLET define("JAVA_SERVLET", "/MyWebApp/servlet.phpjavabridge")
JAVA_PREFER_VALUES define("JAVA_PREFER_VALUES", 1)
JAVA_LOG_LEVEL define("JAVA_LOG_LEVEL", null)
JAVA_SEND_SIZE define("JAVA_SEND_SIZE", 8192)
JAVA_RECV_SIZE define("JAVA_RECV_SIZE", 8192)
JAVA_DISABLE_AUTOLOAD Not applicable anymore - PSR4 ;)

Initialization

Old way New way
include(... /Java.inc) $ba = new Bridge\Adapter($option);

API

The following table maps old and new recommended API., (*17)

Legacy Bridge\Adapter ($ba)
new Java($class, $args=null) : Java $ba->java($class, $args=null) : Interfaces\JavaObject
java_class($class) : JavaClass $ba->javaClass($class) Interfaces\JavaClass
java_instanceof($object, $class) : boolean $ba->isInstanceOf($object, $class) : boolean

(under review, soon to be implemented), (*18)

Legacy Bridge\Adapter ($ba)
java_values($object) : mixed $ba->getValues($object) : mixed
java_invoke($object, $method, $args=null) : `mixed null|$ba->invokeMethod($object, $method, $args=null) : string\null
java_inspect($object) : string $ba->debug()->inspect($object) : string
getLastException : Exception $ba->debug()->getLastException() : Exception
clearLastException $ba->debug()->clearLastException()

function java_is_null($value) function java_is_true($value) function java_is_false($value), (*19)

Refactoring guidelines

Keep a step by step approach... you can use both API at the same time., (*20)

  1. Try to change intialization sequence

Coding standards

The Versions

01/03 2017

dev-master

9999999-dev http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

01/03 2017

1.1.0

1.1.0.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

17/02 2017

0.15.0

0.15.0.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

16/01 2017

0.14.0

0.14.0.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

01/12 2016

0.13.0

0.13.0.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

28/11 2016

0.12.1

0.12.1.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

05/07 2016

0.12.0

0.12.0.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

04/07 2016

0.11.5

0.11.5.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge

11/06 2016

0.11.0

0.11.0.0 http://soluble.io

Soluble PHP Java bridge PJB62 compatibility layer

  Sources   Download

MIT

The Requires

 

The Development Requires

java bridge compatibility phpjavabridge