定制 n-car/rpc-php-toolkit 二次开发

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

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

n-car/rpc-php-toolkit

Composer 安装命令:

composer require n-car/rpc-php-toolkit

包简介

PHP JSON-RPC 2.0 client/server toolkit with middleware, schema validation, batch processing, introspection, and optional Safe Mode

README 文档

README

CI Packagist Version Packagist Downloads PHP Version License Status

PHP JSON-RPC 2.0 client/server toolkit with middleware, schema validation, batch processing, introspection, and optional RPC Toolkit Safe Mode.

Use this package when you need a PHP JSON-RPC endpoint, a PHP HTTP client, or a PHP runtime that interoperates with the broader RPC Toolkit ecosystem.

Standard First

Standard JSON-RPC 2.0 is the default behavior. Enable RPC Toolkit Safe Mode only when both sides are compatible endpoints and need type-aware round-tripping for marker-like strings, dates, and large integer markers.

Installation

Install from Packagist with Composer:

composer require n-car/rpc-php-toolkit

Quick Start

<?php
require_once 'vendor/autoload.php';

use RpcPhpToolkit\RpcEndpoint;

$rpc = new RpcEndpoint('/api/rpc');

$rpc->addMethod('getTime', function($params, $context) {
    return [
        'timestamp' => time(),
        'datetime' => date('c')
    ];
});

$rpc->addMethod('echo', function($params, $context) {
    return ['message' => $params['message'] ?? 'Hello World'];
});

$input = file_get_contents('php://input');
echo $rpc->handleRequest($input);

PHP Client

use RpcPhpToolkit\Client\RpcClient;

$client = new RpcClient('http://localhost:8000/api/rpc');

$time = $client->call('getTime');
$echo = $client->call('echo', ['message' => 'Hello']);

$results = $client->batch([
    ['method' => 'getTime', 'id' => 1],
    ['method' => 'echo', 'params' => ['message' => 'Batch'], 'id' => 2],
]);

$client->notify('log.event', ['source' => 'php-client']);

Key Capabilities

  • JSON-RPC 2.0 calls, notifications, and batch requests
  • PHP endpoint and PHP HTTP client
  • Middleware for CORS, authentication, rate limiting, and custom request processing
  • Schema validation for method parameters
  • Optional introspection through __rpc.* methods
  • Optional RPC Toolkit Safe Mode over HTTP headers
  • Structured logging hooks and configurable error sanitization

Advanced Documentation

  • Clients - PHP client, Safe client, batch calls, notifications, and browser/Node.js client notes.
  • Schema Validation - method parameter schemas and validation errors.
  • Introspection - __rpc.listMethods, __rpc.describe, __rpc.describeAll, __rpc.version, and __rpc.capabilities.
  • Middleware - CORS, authentication, rate limiting, and custom middleware.
  • Safe Mode - optional type-aware serialization, headers, marker behavior, and PHP type notes.
  • Security - production hardening notes for validation, authentication, CORS, errors, and TLS.

Examples

The examples/ folder contains runnable PHP and cross-runtime examples:

Quick local server:

cd examples
php -S localhost:8000 basic-server.php

Related Packages

License

MIT. See LICENSE.

n-car/rpc-php-toolkit 适用场景与选型建议

n-car/rpc-php-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2026 年 06 月 11 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rpc」 「php」 「client」 「toolkit」 「validation」 「server」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 n-car/rpc-php-toolkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 n-car/rpc-php-toolkit 我们能提供哪些服务?
定制开发 / 二次开发

基于 n-car/rpc-php-toolkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-06-11