tourze/json-rpc-http-endpoint-bundle
最新稳定版本:1.0.0
Composer 安装命令:
composer require tourze/json-rpc-http-endpoint-bundle
包简介
JsonRPC HTTP入口模块
README 文档
README
[
]
(https://github.com/tourze/php-monorepo/actions)
[
]
(https://codecov.io/gh/tourze/php-monorepo)
A Symfony bundle that provides HTTP endpoints for JSON-RPC services. This bundle creates HTTP controllers that expose JSON-RPC endpoints with support for POST, GET, and OPTIONS methods, as well as JSONP callbacks.
Installation
composer require tourze/json-rpc-http-endpoint-bundle
Quick Start
- Add the bundle to your
config/bundles.php:
<?php return [ // ... other bundles Tourze\JsonRPCHttpEndpointBundle\JsonRPCHttpEndpointBundle::class => ['all' => true], ];
- The bundle automatically registers HTTP endpoints for JSON-RPC:
POST /json-rpc- Main JSON-RPC endpointGET /json-rpc- GET method with__payloadparameterOPTIONS /json-rpc- CORS preflight support
Features
- Multiple HTTP Methods: Supports POST, GET, and OPTIONS requests
- JSONP Support: GET requests support JSONP callbacks
- CORS Support: Built-in CORS headers for cross-origin requests
- Legacy Routes: Backward compatibility with existing API endpoints
- Automatic Service Discovery: Uses attribute-based controller loading
Usage
POST Requests
Send JSON-RPC requests via POST:
curl -X POST http://your-app.com/json-rpc \ -H "Content-Type: application/json" \ -d '{"jsonrpc": "2.0", "method": "your.method", "params": {"param1": "value1"}, "id": 1}'
GET Requests
Send JSON-RPC requests via GET with __payload parameter:
curl "http://your-app.com/json-rpc?__payload=%7B%22jsonrpc%22%3A%222.0%22%2C%22method%22%3A%22your.method%22%2C%22params%22%3A%7B%22param1%22%3A%22value1%22%7D%2C%22id%22%3A1%7D"
JSONP Support
For JSONP requests, add a callback parameter:
curl "http://your-app.com/json-rpc?callback=myCallback&__payload=%7B...%7D"
Configuration
The bundle works with the JSON-RPC endpoint system and requires the following dependencies:
tourze/json-rpc-endpoint-bundle- Core JSON-RPC endpoint functionalitytourze/json-rpc-core- JSON-RPC protocol implementation
Available Routes
| Method | Path | Name | Description |
|---|---|---|---|
| POST | /json-rpc |
json_rpc_http_server_endpoint |
Main JSON-RPC endpoint |
| POST | /server/json-rpc |
json_rpc_http_server_endpoint__legacy-1 |
Legacy endpoint |
| GET | /json-rpc |
json_rpc_http_server_endpoint_get |
GET method endpoint |
| GET | /api/json-rpc |
json_rpc_http_api_endpoint_legacy |
Legacy GET endpoint |
| OPTIONS | /json-rpc |
- | CORS preflight support |
License
This package is licensed under the MIT License. See the LICENSE file for details.
统计信息
- 总下载量: 81
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 2
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-27