定制 sajya/client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

sajya/client

最新稳定版本:1.4.1

Composer 安装命令:

composer require sajya/client

包简介

HTTP client and server for JSON-RPC 2.0

README 文档

README

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.

统计信息

  • 总下载量: 956.26k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 21
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 3

GitHub 信息

  • Stars: 21
  • Watchers: 2
  • Forks: 5
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-07-08

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固