Download the PHP package jalle19/simple-json-rpc-client without Composer
On this page you can find all versions of the php package jalle19/simple-json-rpc-client. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download jalle19/simple-json-rpc-client
More information about jalle19/simple-json-rpc-client
Files in jalle19/simple-json-rpc-client
Package simple-json-rpc-client
Short Description Simple JSON-RPC 2.0 client which utilizes Zend for HTTP functionality
License BSD-2-Clause
Homepage https://github.com/Jalle19/simple-json-rpc-client
Informations about the package simple-json-rpc-client
simple-json-rpc-client
Simple yet powerful JSON-RPC client which fully implements the JSON-RPC 2.0 specifications. It provides an interface for creating custom clients and comes with a default implementation which sends requests over HTTP using POST. Being standard-compliant it supports standard requests, notifications as well as batch requests.
Requirements
PHP 5.4 is required.
Installation
Install using Composer (the package is published on Packagist). Install with --no-dev
if you don't want or need the ability to run the test suite.
Usage
Standard requests
Notifications
Batch requests
Exception handling
All exceptions derive from the base class BaseException. If you don't want to handle specific exceptions differently from others you can simply catch BaseException like in the examples above. Here's an example which illustrates the exception hierarchy:
Error handling
Some JSON-RPC servers may return a "data" property in their response error. This property may contain valuable information as to the nature of the error. The special ResponseErrorException is thrown whenever a response indicates an error. The exception has a getData()
method which returns an object representation of the error data.
Flags
The client constructor takes a set of flags as the forth parameter. These flags can be used to alter the behavior of the client, mostly useful for working with buggy servers. For example, the FLAG_ATTEMPT_UTF8_RECOVERY
flag will cause the Response class to attempt to avoid "Malformed UTF-8 in response" errors by re-encoding the raw response as UTF-8 before passing it to json_decode()
. This is only done if the raw response is determined not to be valid UTF-8.
Test suite
Run vendor/bin/phpunit
in the project root folder to run the unit tests. The test suite will launch a mock JSON-RPC server on localhost:8585 using PHP's internal web server. If this port is not available on your system you can change it by editing phpunit.xml
.
License
This code is licensed under the New BSD License