switon / rpc
Queue-backed synchronous request-reply calls between PHP handlers for Switon Framework
v1.0.0
2026-06-06 13:43 UTC
Requires
- php: >=8.3
- switon/core: ^1.0
- switon/event: ^1.0
- switon/executor: ^1.0
- switon/invoker: ^1.0
- switon/queue: ^1.0
Requires (Dev)
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^2.0
- switon/testing: ^1.0
README
Switon's queue-backed request-reply RPC for mapped method calls, daemon workers, and reply/error handling.
Highlights
- Request-reply flow:
RpcInterface::call()sends one request and waits for the matching reply. - Method mapping: RPC names can target methods or configured aliases.
- Daemon worker: requests can be pulled from a queue and dispatched by the invoker.
- Clear failure types: timeout, remote, protocol, and method failures are separated.
- Queue-backed transport: request handling is built around queued work.
Installation
composer require switon/rpc
Quick Start
use Switon\Core\Attribute\Autowired; use Switon\Rpc\RpcInterface; class UserService { #[Autowired] protected RpcInterface $rpc; public function profile(int $userId): array { return $this->rpc->call(UserProfileService::class . '::profile', ['userId' => $userId]); } } class UserProfileService { public function profile(int $userId): array { return ['id' => $userId, 'name' => 'mark']; } }
Docs: https://docs.switon.dev/latest/rpc
License
MIT.