Download the PHP package kba-team/json-rpc without Composer

On this page you can find all versions of the php package kba-team/json-rpc. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package json-rpc

JSON-RPC PHP Client and Server

A simple JSON-RPC client/server that just works.

This is fork of matasarei/JsonRPC which in turn is a fork of fguillot/JsonRPC.

Features

Author

Frédéric Guillot

Installation with Composer

For PHP >= 7.4

Running Test Cases

  1. Clone the repo
  2. cd JsonRPC
  3. Run composer: composer install
  4. Run tests: vendor/bin/phpunit

Examples

Server

Callback binding:

Callback binding from array:

Class/Method binding:

Class/Method binding from array:

Server Middleware:

Middleware might be used to authenticate and authorize the client. They are executed before each procedure.

You can raise a AuthenticationFailureException when the API credentials are wrong or a AccessDeniedException when the user is not allowed to access to the procedure.

Client

Example with positional parameters:

Example with named arguments:

Arguments are called in the right order.

Examples with the magic method __call():

The example above use positional arguments for the request and this one use named arguments:

Client batch requests

Call several procedures in a single HTTP request:

All results are stored at the same position of the call.

Client exceptions

Client exceptions are normally thrown when an error is returned by the server. You can change this behaviour by using the $returnException argument which causes exceptions to be returned. This can be extremely useful when executing the batch request.

Enable client debugging

You can enable the debug mode to see the JSON request and response:

The debug output is sent to the PHP system logger. You can configure the log destination in your php.ini.

Output example:

IP based client restrictions

The server can allow only some IP addresses:

If the client is blocked, you got a 403 Forbidden HTTP response.

HTTP Basic Authentication

If you use HTTPS, you can allow client by using a username/password.

On the client, set credentials like that:

If the authentication failed, the client throw a RuntimeException.

Using an alternative authentication header:

The example above will use the HTTP header X-Authentication instead of the standard Authorization: Basic [BASE64_CREDENTIALS]. The username/password values need be encoded in base64: base64_encode('username:password').

Local Exceptions

By default, the server will relay all exceptions to the client. If you would like to relay only some of them, use the method Server::withLocalException($exception):

Callback before client request

You can use a callback to change the HTTP headers or the URL before to make the request to the server.

Example:


All versions of json-rpc with dependencies

PHP Build Version
Package Version
Requires php Version >=7.4
ext-json Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package kba-team/json-rpc contains the following files

Loading the files please wait ....