承接 yocto/yoclib-jsonrpc 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

yocto/yoclib-jsonrpc

最新稳定版本:v1.0.1

Composer 安装命令:

composer require yocto/yoclib-jsonrpc

包简介

This yocLibrary enables your project to encode and decode JSON-RPC messages in PHP.

README 文档

README

This yocLibrary enables your project to encode and decode JSON-RPC messages in PHP.

Status

PHP Composer codecov

Installation

composer require yocto/yoclib-jsonrpc

Use

Serialization

use YOCLIB\JSONRPC\JSONRPCException;
use YOCLIB\JSONRPC\Message;

// Create request
$message = Message::createRequest(123,'getInfo',['payments']);
// Create notification
$message = Message::createNotification('notificationEvent',['payed']);
// Create response
$message = Message::createResponse(123,['payments'=>['$10.12','$23.45','$12.34']]);

$object = $message->toObject();

try{
    $json = Message::encodeJSON($object);
}catch(JSONRPCException $e){
    //Handle encoding exception
}

Deserialization

use YOCLIB\JSONRPC\JSONRPCException;
use YOCLIB\JSONRPC\Message;

$json = file_get_contents('php://input'); // Get request body

try{
    $object = Message::decodeJSON($json);
}catch(JSONRPCException $e){
    //Handle decoding exception
}

if(Message::isBatch($object)){
    foreach($object AS $element){
        try{
            $message = Message::parse($element);
        }catch(JSONRPCException $e){
            //Handle message exception
        }
    }
}else{
    try{
        $message = Message::parse($object);
    }catch(JSONRPCException $e){
        //Handle message exception
    }
}

统计信息

  • 总下载量: 6
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 0
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: GPL-3.0-or-later
  • 更新时间: 2024-05-17