⚠ This page is served via a proxy. Original site: https://github.com
This service does not collect credentials or authentication data.
Skip to content

sajya/client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

102 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Introduction

run-tests

This package lets you set up a JSON-RPC client over HTTP(S), using your PHP code to make the requests. Built around Laravel (Doesn't require the entire framework, just its component) expressive HTTP wrapper, it allows you to customize things like authorization, retries, and more.

Install

Go to the project directory and run the command:

$ composer require sajya/client

Usage

use Illuminate\Support\Facades\Http;
use Sajya\Client\Client;

$client = new Client(Http::baseUrl('http://localhost:8000/api/v1/endpoint'));

$response = $client->execute('tennis@ping');

$response->result(); // pong

By default, the request identifier will be generated using the UUID, you can get it by calling the id() method

$response->id();

To get the result of an error, you need to call the error() method

$response->error();

Parameters

Example with positional parameters:

$response = $client->execute('tennis@ping', [3, 5]);

Example with named arguments:

$response = $client->execute('tennis@ping', ['end' => 10, 'start' => 1]);

Batch requests

Call several procedures in a single HTTP request:

$batchData = $client->batch(function (Client $client) {
    $client->execute('tennis@ping');
    $client->execute('tennis@ping');
});

Notify requests

$client->notify('procedure@method');

License

The MIT License (MIT). Please see License File for more information.

About

JSON-RPC 2.0 HTTP(S) Client

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages