定制 maoxuner/laravel-jsonrpc 二次开发

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

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

maoxuner/laravel-jsonrpc

最新稳定版本:v1.3.1

Composer 安装命令:

composer require maoxuner/laravel-jsonrpc

包简介

JSON-RPC 2.0 Server/Client For Laravel

README 文档

README

Entrypoint

Add route for jsonrpc entrypoint

\Illuminate\Support\Facades\Route::post('/jsonrpc', 'maoxuner\LaravelJsonRpc\Server\Server@entrypoint');

Configure

php artisan vendor:publish --tags=jsonrpc

Do some modification such as changing namespace to App\\Actions

Create a procedure

Create a procedure class under the namespace configured before with a public function handle.

<?php

namespace App\Actions;

class Ping
{
    public function handle(): string
    {
        return 'Pong';
    }
}
<?php

namespace App\Actions;

class Say
{
    public function handle(string $name, string $foo = 'foo', ?string $bar = null): array
    {
        return [
            'message' => 'Hello, '.$name.'!',
            'foo' => $foo,
            'bar' => $bar,
        ];
    }
}

Test Client

Use tinker create a client and then call Ping procedure. Params are supported by passing param position/name indexed array as second argument to execute.

php artisan tinker
$client = new \maoxuner\LaravelJsonRpc\Client\Client(\Illuminate\Support\Facades\Http::baseUrl('http://foo-bar/jsonrpc'));
echo $client->execute('Ping');
dump($client->execute('Say', ['World', 'oof']));
dump($client->execute('Say', ['bar' => 'rab', 'name' => 'World']));

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-03-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固