tourze / json-rpc-procedure-collect-bundle
JSON-RPC过程收集模块
Installs: 4
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/json-rpc-procedure-collect-bundle
Requires
- php: ^8.1
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
- symfony/stopwatch: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/json-rpc-core: ^0.0.6
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-01 19:18:43 UTC
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.