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
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:
basic-server.php- HTTP endpoint with middleware and validation examples.client.php- PHP client calls, batch requests, authentication, and errors.safe-mode-example.php-RpcSafeEndpointandRpcSafeClientusage.php-to-express-client.php- PHP client calling an Express RPC endpoint.node-to-php-client.mjs- JavaScript client calling a PHP endpoint.examples/introspection/- introspection server/client examples.
Quick local server:
cd examples
php -S localhost:8000 basic-server.php
Related Packages
- rpc-toolkit - ecosystem hub and compatibility reference
- rpc-express-toolkit - Express implementation
- rpc-node-toolkit - framework-agnostic Node.js core
- rpc-toolkit-js-client - shared JavaScript client
- rpc-dotnet-toolkit - .NET implementation
- rpc-java-toolkit - Java and Android implementation
- rpc-python-toolkit - Python implementation
- rpc-arduino-toolkit - Arduino/ESP32/ESP8266 implementation
- node-red-contrib-rpc-toolkit - Node-RED nodes
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 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 n-car/rpc-php-toolkit 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Microservice RPC through message queues.
Mock PSR-18 HTTP client
Asynchronous MQTT client built on React
Control Nginx as a reverse proxy through plinker RPC
A API library that make it easy to access the Webuntis JSON RPC 2.0 API
Client for Google Directions API to add interpolated points to a route consisting of given coordinates.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 33
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-06-11