Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jsonrpc Laravel Package

agentsib/jsonrpc

View on GitHub
Deep Wiki
Context7

Base client

For example:

<?php

use \AgentSIB\JsonRpc\JsonRpcClient;
use \AgentSIB\JsonRpc\Transports\CurlJsonRpcTransport;

$client = new JsonRpcClient(new CurlJsonRpcTransport('http://example.org/jsonrpc'));

try {
    $response = $client->makeSingleRequest('user.testMethod', array('param1' => 'test'));
    
    if ($response->isCorrect()) {
        if ($response->isSuccess()) {
            var_dump($response->getResult());
        } else {
            die($response->getErrorCode(). ': ' .$response->getErrorMessage());
        }
    }
} catch (\Exception $e) {
    // Some curl exception
}

You can use single requests:

$response = $client->makeSingleRequest('user.testMethod', array('param1' => 'test'));

Or notifications:

$client->makeSingleNotification('user.notifyMessage', array('message'=>'test'));

Or batch request:

$response = $client->makeBatchRequest(
    BatchJsonRpcRequest::create()
        ->addRequest(new SingleJsonRpcRequest('user.testMethod', array('param1' => 'test'), 'userinfo'))
        ->addRequest(new NotificationJsonRpcRequest('user.sendMessage', array('message' => 'test2')))
        ->addRequest(new SingleJsonRpcRequest('user.notExistsMethod', null, 'notexist'))
);

if ($response->isCorrect()) {
    echo count($response->getAllResponses()); // 2, because notifications not in response
    echo $response->getRawResponse(); // Input json
    if ($response->getResponseById('userinfo')->isSuccess()){
        var_dump($response->getResponseById('userinfo')->getResult());
    }

    // or

    foreach ($response->getAllResponses() AS $resp) {
        echo $resp->getId();
    }
}
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata