2017 © Pedro Peláez
 

library avro-rpc-php

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

image

eliep/avro-rpc-php

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  • Saturday, August 20, 2016
  • by eliep
  • Repository
  • 4 Watchers
  • 3 Stars
  • 57 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 13 Versions
  • 0 % Grown

The README.md

Avro RPC client for PHP

See Avro for a full documentation on Avro and its usage in PHP., (*1)

This library is a fork of the original Avro library, only adding a php Avro RPC client, (*2)

Installation

composer require eliep/avro-rpc-php

Usage

Create a client for your protocol


/** * $protocol: your Avro protocol as a string * $serverHost: Avro RPC Server Host * $serverPort: Avro RPC Server Port **/ // Parse your avro protocol $avroProtocol = AvroProtocol::parse($protocol); // Connect to the server $client = NettyFramedSocketTransceiver::create($serverHost, $serverPort); // Retrieve a client $requestor = new Requestor($avroProtocol, $client);

Request the server

Simply use the request method of the Requestor instance. This method has two parameters:, (*3)

  • the message name as defined in your avro protocol
  • an array of named parameter as defined by the request part of your message

for example, if your protocol is:, (*4)

{
 ...
 "types": [
     {"type": "record", "name": "SimpleRequest",
      "fields": [{"name": "subject",   "type": "string"}]
     },
     {"type": "record", "name": "SimpleResponse",
      "fields": [{"name": "response",   "type": "string"}]
     }
 ],

 "messages": {
     "testSimpleRequestResponse": {
         "doc" : "Simple Request Response",
         "request": [{"name": "message", "type": "SimpleRequest"}],
         "response": "SimpleResponse"
     }
 }
}
try {
  $response = $requestor->request('testSimpleRequestResponse', array("message" => array("subject" => "pong")));
  echo "Response received: ".json_encode($response)."\n";
} catch (AvroRemoteException $e) {
  // an error occured on the server while handling the request.
}

Example

An RPC client example is located in the examples/sample_rpc_client.php. It can be used with the examples/sample_rpc_server.php to test the client/server communication., (*5)

  • Run php examples/sample_rpc_server.php
  • Then run php examples/sample_rpc_client.php in another console.

Test

Test can be run with:, (*6)

phpunit test/AllTests.php

These are mostly the original Avro test except for the test/IpcTest.php files, (*7)

The Versions

20/08 2016

dev-master

9999999-dev https://github.com/eliep/avro-rpc-php

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Avatar eliep

serialization rpc avro

20/08 2016

1.7.7-p0

1.7.7.0-patch https://github.com/eliep/avro-rpc-php

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Avatar eliep

serialization rpc avro

07/09 2015

0.1.10

0.1.10.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

20/03 2015

0.1.9

0.1.9.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

20/03 2015

0.1.8

0.1.8.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

20/03 2015

0.1.7

0.1.7.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

20/03 2015

0.1.6

0.1.6.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

04/03 2015

0.1.5

0.1.5.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

04/03 2015

0.1.4

0.1.4.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

04/03 2015

0.1.3

0.1.3.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

04/03 2015

0.1.2

0.1.2.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

03/03 2015

0.1.1

0.1.1.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P

03/03 2015

0.1

0.1.0.0

An Avro RPC client in PHP (compatible with the Avro RPC server in Java)

  Sources   Download

Apache-2.0

by Elie P