tourze/json-rpc-procedure-collect-bundle
最新稳定版本:0.0.2
Composer 安装命令:
composer require tourze/json-rpc-procedure-collect-bundle
包简介
JSON-RPC过程收集模块
README 文档
README
A Symfony Bundle that collects all services marked as JSON-RPC methods and provides an API to query all available methods.
Features
- Automatically collect all JSON-RPC methods marked with
#[MethodExpose]attribute - Provide
GetProcedureListJSON-RPC method to retrieve all registered methods - Support for method documentation and tagging via
#[MethodDoc]and#[MethodTag]attributes - Dependency injection integration for automatic service discovery
Installation
composer require tourze/json-rpc-procedure-collect-bundle
Bundle Registration
Add to config/bundles.php:
Tourze\JsonRPCProcedureCollectBundle\JsonRPCProcedureCollectBundle::class => ['all' => true],
Quick Start
Creating a JSON-RPC Method
<?php namespace App\Procedure; use Tourze\JsonRPC\Core\Attribute\MethodDoc; use Tourze\JsonRPC\Core\Attribute\MethodExpose; use Tourze\JsonRPC\Core\Attribute\MethodTag; use Tourze\JsonRPC\Core\Procedure\BaseProcedure; #[MethodTag(name: 'User Service')] #[MethodDoc(summary: 'Get user information')] #[MethodExpose(method: 'GetUserInfo')] class GetUserInfo extends BaseProcedure { public function execute(): array { // Implement your method logic return ['user' => 'data']; } }
Retrieving All Available Methods
Call the GetProcedureList JSON-RPC method to get all registered JSON-RPC methods and their corresponding implementation classes:
{
"jsonrpc": "2.0",
"method": "GetProcedureList",
"params": {},
"id": 1
}
Response example:
{
"jsonrpc": "2.0",
"result": {
"GetProcedureList": "Tourze\\JsonRPCProcedureCollectBundle\\Procedure\\GetProcedureList",
"GetUserInfo": "App\\Procedure\\GetUserInfo"
},
"id": 1
}
Requirements
- PHP >= 8.1
- Symfony >= 7.3
tourze/json-rpc-corepackage
Testing
Run the test suite:
./vendor/bin/phpunit packages/json-rpc-procedure-collect-bundle/tests
Contributing
Please see CONTRIBUTING.md for details.
License
The MIT License (MIT). Please see License File for more information.
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-27