spiral/goridge
Spiral GoRidge is a high-performance PHP↔Go RPC bridge used by RoadRunner. It provides fast inter-process communication via relay transports (pipes, TCP, sockets) with a compact binary protocol, enabling scalable PHP apps and background workers.
composer require spiral/goridgego run worker.go)Goridge\RPC\RPC::createWithOptions('tcp://127.0.0.1:6001') (or UnixSocket, RelaySocket, Stream for local use)$rpc->call('Service.Method', $payload)UnixSocket is recommended for local development for lowest latency.class ImageProcessor {
private $rpc;
public function __construct() {
$this->rpc = RPC::createUnix('/tmp/goridge.sock');
}
public function resize(string $path, int $width): string {
return $this->rpc->call('Image.Resize', [$path, $width]);
}
}
Goridge\Relay for two-way communication—PHP calls Go, and Go can push data back (e.g., streaming logs or progress updates).Stream transport (goridge://tmp/goridge.stream) for local debugging; logs and stack traces are easier to trace than with binary socket protocols.json tags won’t auto-match). Use goridge-go’s msgpack tags if interoperating with Go clients.Goridge\RPC\Exceptions\RemoteException on Go-side panics; always wrap call() in try/catch and inspect $e->getPayload() for Go stack traces.UnixSocket over TCP for same-host communication (5–10x faster).options=['frames' => 1024] to reduce syscall overhead.options=['shared' => false] if memory leaks appear in long-running CLI workers (PHP GC won’t free them otherwise).Relay + stream_get_contents() to mock Go responses in unit tests without spawning processes.Goridge\TransportInterface for custom transports (e.g., Kafka, AMQP) by wrapping their pub/sub semantics around Goridge’s frame-based protocol.How can I help you explore Laravel packages today?