All Projects → belgattitude → Soluble Japha

belgattitude / Soluble Japha

Licence: mit
PHP Java integration

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to Soluble Japha

Emodbus
Modbus library for both RTU and TCP protocols. Primarily developed on and for ESP32 MCUs.
Stars: ✭ 29 (-50.85%)
Mutual labels:  bridge, client
Dsc Mercado Livre
Biblioteca de integração com o Mercado Livre
Stars: ✭ 55 (-6.78%)
Mutual labels:  client
Honeybot
🛩 A python IRC bot with simple plugins dev. Ignited in mauritius, first-timers friendly!
Stars: ✭ 48 (-18.64%)
Mutual labels:  client
Giphy
Go library for the Giphy API
Stars: ✭ 52 (-11.86%)
Mutual labels:  client
Csdnblog
Csdn unofficial blog client
Stars: ✭ 48 (-18.64%)
Mutual labels:  client
Lifion Kinesis
A native Node.js producer and consumer library for Amazon Kinesis Data Streams
Stars: ✭ 54 (-8.47%)
Mutual labels:  client
Twittex
Twitter client library for Elixir.
Stars: ✭ 46 (-22.03%)
Mutual labels:  client
Manaflux
The app needs a rewrite. It might not work anymore. An assistant that can choose your runes, summoner spells, and item sets for League of Legends.
Stars: ✭ 57 (-3.39%)
Mutual labels:  client
Subscriptions Transport Sse
A Server-Side-Events (SSE) client + server for GraphQL subscriptions
Stars: ✭ 55 (-6.78%)
Mutual labels:  client
Fdfs client
fastdfs go client impl
Stars: ✭ 52 (-11.86%)
Mutual labels:  client
Vue Bridge Webview
javascript bridge android/ios webview
Stars: ✭ 52 (-11.86%)
Mutual labels:  bridge
Faunadb Jvm
Scala and Java driver for FaunaDB
Stars: ✭ 50 (-15.25%)
Mutual labels:  client
Nodejs Driver
DataStax Node.js Driver for Apache Cassandra
Stars: ✭ 1,074 (+1720.34%)
Mutual labels:  client
Javascript Cli
A CLI in JavaScript for the ARK Blockchain.
Stars: ✭ 48 (-18.64%)
Mutual labels:  client
Postman
1.12.2 anarchy client :)
Stars: ✭ 54 (-8.47%)
Mutual labels:  client
Graphql Zeus
GraphQL client and GraphQL code generator with GraphQL autocomplete library generation ⚡⚡⚡ for browser,nodejs and react native
Stars: ✭ 1,043 (+1667.8%)
Mutual labels:  client
Megalodon
Mastodon, Pleroma and Misskey API client library for node.js and browser
Stars: ✭ 52 (-11.86%)
Mutual labels:  client
Biota
A simple database framework for Fauna
Stars: ✭ 54 (-8.47%)
Mutual labels:  client
Bottyclient
A slim Discord client with many cool features including less network traffic which supports bot tokens, but user tokens theoretically work too. Tags: Discord Bot Client Token for Bot Botting Download English
Stars: ✭ 58 (-1.69%)
Mutual labels:  client
Adrestia
APIs & SDK for interacting with Cardano.
Stars: ✭ 56 (-5.08%)
Mutual labels:  client

soluble-japha

PHP Version PHP Version Build Status codecov Scrutinizer Code Quality Latest Stable Version Total Downloads License

In short soluble-japha allows to write Java code in PHP and interact with the JVM ecosystem.


Read the doc on https://belgattitude.github.io/soluble-japha website for complete information


As meaningless examples:

<?php
// Some standard JVM classes
$hashMap = $ba->java('java.util.HashMap', [
        'message' => 'Hello world',
        'value'   => $ba->java('java.math.BigInteger', PHP_INT_MAX)
]);
$hashMap->put('message', '你好,世界');
echo $hashMap->get('message');

<?php

use Soluble\Japha\Bridge\Exception;

// An imaginary java library class (i.e. NLP, Android, Jasper, Tensorflow,
// enterprise stuff, esoteric java lib/driver or your own Java class...)
try {
    $javaLib = $ba->java('an.imaginary.JavaLibraryClass', 'param1', 'param2');

    $results = $javaLib->aMethodOnJavaLibExecutedOnTheJVM(
                            // Method parameters
                            $hashMap->get('message'),
                            $ba->java('java.io.BufferedReader',
                                 $ba->java('java.io.FileReader', __FILE__)
                            ),
                            $ba->javaClass('java.util.TimeZone')->SHORT
                        );

    foreach ($results as $key => $values) {
        echo "$key: " . $values[0] . PHP_EOL;
    }
} catch (Exception\ClassNotFoundException $e) {
    echo $e->getMessage();
} catch (Exception\JavaException $e) {
    echo $e->getMessage() . ' [' . $e->getJavaClassName() . ']';
    echo $e->getStackTrace();
}

And if you're wondering what's the $ba object, it's a connection to the java bridge server:

<?php

use Soluble\Japha\Bridge\Adapter as BridgeAdapter;
use Soluble\Japha\Bridge\Exception as BridgeException;

$options = [
    'servlet_address' => 'localhost:8080/MyJavaBridge/servlet.phpjavabridge'
];

try {
    $ba = new BridgeAdapter($options);
} catch (BridgeException\ConnectionException $e) {
    // Server is not reachable
    echo $e->getMessage();
}

Use cases

Expand the PHP horizons to the Java ecosystem, especially whenever you want to take advantage of

The freedom allowed by soluble-japha is not fit for every scenarios. Be sure to read the considerations and performance sections to learn more.

Features

soluble-japha provides a PHP client to interact with the Java Virtual Machine.

  • [x] Write Java code from PHP (in a similar way from equivalent java code).
  • [x] Keep programmatic code control from the PHP side (function oriented vs REST).
  • [x] Java execution on the JVM ensuring compatibility and efficiency (proxied objects).
  • [x] No need to write a service layer prior to usage (the Java object is the contract).
  • [x] Fast network based communication between runtimes, no JVM startup effort.
  • [x] Solid foundation to create, develop or publish PHP wrappers over java libs.

For user of previous versions, soluble-japha client replaces the original/legacy PHPJavaBridge Java.inc implementation and has been completely refactored to fit modern practices and PHP7. See the differences here and the legacy compatibility layer if needed.

Requirements

  • Version ^2.0 requires PHP 7.1 PHP Version

Important. There's NO API BC-BREAK between v0.13, v1.x and v2.x so you should be able to upgrade safely between releases. The choice to increment version numbers to drop support for older php versions was made to avoid any confusion with multiple php installs.

If you're looking for compatibility with older PHP versions, note that:

  • Version ^1.0 requires PHP 5.6 PHP Version and works with HHVM.
  • Version ^0.13 requires PHP 5.5 PHP Version and works with HHVM.

Documentation

Installation

Installation in your PHP project (client)

$ composer require soluble/japha

Considerations

In short, the bridge shines whenever you need to use directly a Java library within a reasonable number of method calls. Otherwise implement REST or RPC approaches for first-class system integrations.

The soluble-japha bridge can be seen as a function oriented solution in comparison to resource oriented ones (i.e. REST,...). From REST or even RPC-based solutions (XMLRPC, JsonRPC or gRPC), the bridge skips the need to write a service layer on the Java side and allows a more programmatic approach to PHP developers.

Depending on usage, the benefits of freedom offered by the bridge can become a limitation in term of performance. Keep in mind that the bridge is sensitive to the number of objects and method calls (named roundtrips) and if few hundreds of methods calls are often insignificant (a roundtrip is generally less than 0.1ms) going further its target scenarios can be disappointing. In those case, traditional approaches like REST should be considered and applied instead.

That said, the bridge is a good, reliable and sometimes preferable alternative over REST for scenarios where a reasonable number of methods calls is intended.

Be sure to read the

Support

Please fill any issues on the offical tracker. If you like to contribute, see the contribution guidelines. All P/R are warmly welcomed.

Credits

Special mention

Grateful thanks to JetBrains for granting an opensource license of PHPStorm and Idea. Really recommend !!!

PHPStorm

Coding standards and interop

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].