PHPackages                             upgate/laravel-jsonrpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. upgate/laravel-jsonrpc

ActiveLibrary[API Development](/categories/api)

upgate/laravel-jsonrpc
======================

Laravel JSON-RPC 2.0 Server

0.7.11(11mo ago)5346.8k↓66.1%9BSD-2-ClausePHPPHP &gt;=7.2|&gt;=8.0CI failing

Since Nov 2Pushed 11mo ago3 watchersCompare

[ Source](https://github.com/upgate/laravel-jsonrpc)[ Packagist](https://packagist.org/packages/upgate/laravel-jsonrpc)[ RSS](/packages/upgate-laravel-jsonrpc/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (10)Dependencies (9)Versions (33)Used By (0)

JSON-RPC Server for Laravel/Lumen
=================================

[](#json-rpc-server-for-laravellumen)

[![Build Status](https://camo.githubusercontent.com/53bec20e72b8bdbe87063beb3d1d4b6ed5617f0728cfda21e7b5e6a2357b98c7/68747470733a2f2f636972636c6563692e636f6d2f67682f7570676174652f6c61726176656c2d6a736f6e7270632e7376673f7374796c653d736869656c64)](https://app.circleci.com/pipelines/github/upgate/laravel-jsonrpc) [![StandWithUkraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/badges/StandWithUkraine.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

[![Stand With Ukraine](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://vshymanskyy.github.io/StandWithUkraine/)

### 📢 [Updates from Ukrainian Open Source Community](https://stand-with-ukraine.pp.ua/CommunityUpdates.html)

[](#-updates-from-ukrainian-open-source-community)

### 🇷🇺 [Обращение к гражданам России](https://stand-with-ukraine.pp.ua/ToRussianPeople.html)

[](#-обращение-к-гражданам-россии)

Quick How-To
------------

[](#quick-how-to)

- Install with composer: `composer require upgate/laravel-jsonrpc`
- In your RouteServiceProvider, do something like this:

```
// ...
use Upgate\LaravelJsonRpc\Contract\ServerInterface as JsonRpcServerContract;

class RouteServiceProvider extends ServiceProvider
{
    // ...
    public function map(Router $router)
    {
        $router->group(
            ['namespace' => $this->namespace],
            function (Router $router) {
                // Create an instance of JsonRpcServer
                $jsonRpcServer = $this->app->make(JsonRpcServerContract::class);
                // Set default controller namespace
                $jsonRpcServer->setControllerNamespace($this->namespace);
                // Register middleware aliases configured for Laravel router
                $jsonRpcServer->registerMiddlewareAliases($router->getMiddleware());

                require app_path('Http/routes.php');
            }
        );
    }
}
```

- Use $jsonRpcServer in your routes.php, like this:

```
$router->post('/jsonrpc', function (Illuminate\Http\Request $request) use ($jsonRpcServer) {
    $jsonRpcServer->router()
        ->addMiddlewares(['fooMiddleware', 'barMiddleware', 'auth:rpcGuard']) // Middleware alias names or class names.
                                                                              // Parameters may be specified by separating
                                                                              // the middleware name and parameters with a :
        ->bindController('foo', 'FooController') // for 'foo.$method' methods invoke FooController->$method(),
                                                 // for 'foo' method invoke FooConroller->index()
        ->bind('bar', 'MyController@bar') // for 'bar' method invoke MyController->bar()
        ->group(
            ['bazMiddleware'], // add bazMiddleware for methods in this group
            function ($jsonRpcRouter) {
                // for 'bar.baz' method invoke MyController->bazz()
                $jsonRpcRouter->bind('bar.baz', 'MyController@bazz');
            }
        );

    // Run json-rpc server with $request passed to middlewares as a handle() method argument
    return $jsonRpcServer->run($request);
});
```

See `ServerTest` and `RouterTest` for more examples.

Exception handling
------------------

[](#exception-handling)

Descendants of `Upgate\LaravelJsonRpc\Exception\JsonRpcException` represent JSON-RPC errors according to the spec (see `Upgate\LaravelJsonRpc\Server\ErrorCode`).

Other exceptions are logged and converted to INTERNAL\_ERROR responses by default.

Use `Upgate\LaravelJsonRpc\Server\Server::onException()` to register custom exception handlers:

```
use Upgate\LaravelJsonRpc\Server;

$jsonRpcServer->onException(
    SomeExceptionClass::class,
    function (SomeExceptionClass $e, Server\Request $request = null) {
        $message = "Some Message";
        $code = -32099;
        return Server\RequestResponse::constructErrorResponse($request ? $request->getId() : null, $message, $code);
    }
);

$jsonRpcServer->onException(
    \Throwable::class, // catch-all
    function (\Throwable $e, Server\Request $request = null) {
        $message = "Some Other Message";
        $code = -32098;
        return Server\RequestResponse::constructErrorResponse($request ? $request->getId() : null, $message, $code);
    }
);
```

See `ServerTest:: testSingleRequestWithExceptionHandler()` and `ServerTest::testExceptionHandlersPriority()` for more examples.

JSON-RPC Request Forms
----------------------

[](#json-rpc-request-forms)

(since v0.3.0)

`Upgate\LaravelJsonRpc\Server\FormRequest` is similar to Laravel form requests, but validates JSON-RPC parameters instead.

Example:

```
use Upgate\LaravelJsonRpc\Server\FormRequest as JsonRpcFormRequest;

class MyJsonRpcFormRequest extends JsonRpcFormRequest
{
    public function rules(): array
    {
        return [
            'id'    => 'required|numeric',
            'email' => 'required|email',
        ];
    }
}

class MyController
{
    public function myAction(MyJsonRpcFormRequest $jsonRpcRequest)
    {
        $email = $jsonRpcRequest->email; // or $jsonRpcRequest->get('email');
        $allParams = $jsonRpcRequest->all();
        // ...
    }
}
```

If validation fails, the INVALID\_PARAMS error response is returned, with validation error details in `data.violations`.

See the `ServerFormRequestTest` for more examples.

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance50

Moderate activity, may be stable

Popularity42

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 92.8% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~119 days

Recently: every ~299 days

Total

31

Last Release

353d ago

PHP version history (5 changes)0.1.0PHP &gt;=5.5.0

0.2.0PHP &gt;=7.0

0.2.2PHP &gt;=7.1

0.6.0PHP &gt;=7.2

0.7.4PHP &gt;=7.2|&gt;=8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7947177?v=4)[Konstantin Baryshnikov](/maintainers/kbaryshnikov)[@kbaryshnikov](https://github.com/kbaryshnikov)

![](https://www.gravatar.com/avatar/e1deca88a550d0e02b5a78ff7f9a73ac5d184f3973b4e9dbdf3c12a37d7fb15a?d=identicon)[upgate](/maintainers/upgate)

---

Top Contributors

[![kbaryshnikov](https://avatars.githubusercontent.com/u/7947177?v=4)](https://github.com/kbaryshnikov "kbaryshnikov (90 commits)")[![s-chizhik](https://avatars.githubusercontent.com/u/5587936?v=4)](https://github.com/s-chizhik "s-chizhik (5 commits)")[![Bradez](https://avatars.githubusercontent.com/u/919214?v=4)](https://github.com/Bradez "Bradez (1 commits)")[![sergiizeleniy](https://avatars.githubusercontent.com/u/22545614?v=4)](https://github.com/sergiizeleniy "sergiizeleniy (1 commits)")

---

Tags

laraveljson-rpc

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/upgate-laravel-jsonrpc/health.svg)

```
[![Health](https://phpackages.com/badges/upgate-laravel-jsonrpc/health.svg)](https://phpackages.com/packages/upgate-laravel-jsonrpc)
```

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3345.4M354](/packages/psalm-plugin-laravel)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

265.2k](/packages/aedart-athenaeum)[illuminate/routing

The Illuminate Routing package.

1239.4M3.5k](/packages/illuminate-routing)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

818355.4k3](/packages/defstudio-telegraph)[laravel/mcp

Rapidly build MCP servers for your Laravel applications.

79227.1M230](/packages/laravel-mcp)[api-platform/laravel

API Platform support for Laravel

58190.1k21](/packages/api-platform-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
