spiral / roadrunner-grpc
gRPC server for PHP: serve gRPC services from RoadRunner PHP workers
Fund package maintenance!
Requires
- php: >=8.2
- ext-json: *
- google/common-protos: ^3.1|^4.0
- google/protobuf: ^3.7 || ^4.0 || ^5.0
- roadrunner/goridge: ^4.5
- roadrunner/worker: ^3.8
- spiral/roadrunner: ^3.0
- symfony/polyfill-php83: ^1.27
Requires (Dev)
- jetbrains/phpstorm-attributes: ^1.0
- mockery/mockery: ^1.6
- spiral/code-style: ^2.3.1
- spiral/dumper: ^3.3
- testo/bridge-mockery: ^0.1.2
- testo/testo: ^0.10.55
- vimeo/psalm: ^6 || ^7
Suggests
None
Provides
None
Conflicts
None
Replaces
- spiral/roadrunner-grpc: 3.8.0
- 3.x-dev
- 3.8.0
- v3.7.0
- v3.6.0
- v3.5.2
- v3.5.1
- v3.5.0
- v3.4.3
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.0
- 3.2.0
- 3.1.0
- 3.0.1
- 3.0.0
- 2.x-dev
- v2.0.1
- v2.0.0
- 1.x-dev
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.1
- v1.3.0
- v1.2.2
- v1.2.1
- v1.2.0
- v1.1.1
- v1.1.0
- v1.0.8
- v1.0.7
- v1.0.6
- v1.0.5
- v1.0.4
- v1.0.3
- v1.0.2
- v1.0.1
- v1.0.0
- dev-release-please--branches--3.x--components--roadrunner/grpc
- dev-ci/tag-without-v
- dev-release-please--branches--3.x--components--spiral/roadrunner-grpc
- dev-rr-v3
- dev-static-analysis
- dev-ci/mutation-testing
- dev-coverage
- dev-testo
- dev-ci/code-style
- dev-chore/codeowners
- dev-docs/readme
- dev-ci/security-audit
- dev-ci/release-please
This package is auto-updated.
Last update: 2026-10-10 14:08:28 UTC
README
High-performance gRPC server for PHP applications
RoadRunner GRPC is the PHP side of the RoadRunner gRPC plugin. It runs your PHP gRPC services inside RoadRunner workers, so PHP and Golang services can live within one application.
Get Started
Installation
composer require roadrunner/grpc
Configuration
Enable the grpc plugin in .rr.yaml and point it at your .proto files:
version: "3" server: command: "php worker.php" grpc: listen: "tcp://127.0.0.1:9001" proto: ["service.proto"]
All available options are described in the plugin documentation.
Generating Service Code
Service interfaces and messages are generated from .proto files with protoc and the protoc-gen-php-grpc plugin,
which can be downloaded from the RoadRunner releases page:
protoc --php_out=src --php-grpc_out=src service.proto
Writing a Service
Implement the generated interface:
use Service\EchoInterface; use Service\Message; use Spiral\RoadRunner\GRPC\ContextInterface; final class EchoService implements EchoInterface { public function Ping(ContextInterface $ctx, Message $in): Message { return (new Message())->setMsg(\date('Y-m-d H:i:s') . ': PONG'); } }
Running the Worker
Register the service in worker.php and start serving requests:
use Service\EchoInterface; use Spiral\RoadRunner\GRPC\Invoker; use Spiral\RoadRunner\GRPC\Server; use Spiral\RoadRunner\Worker; require __DIR__ . '/vendor/autoload.php'; $server = new Server(new Invoker(), [ 'debug' => false, // optional (default: false) ]); $server->registerService(EchoInterface::class, new EchoService()); $server->serve(Worker::create());
Then run rr serve. A complete echo service with a client is in the example directory.
Features
- native Golang GRPC implementation compliant
- minimal configuration, plug-and-play model
- very fast, low footprint proxy
- simple TLS configuration
- debug tools included
- Prometheus metrics
- middleware and server customization support
- code generation using the
protoc-gen-php-grpcplugin forprotoc(download the version matching your RoadRunner, e.g.protoc-gen-php-grpc-3.0.0-*, from the roadrunner releases page) - transport, message, worker error management
- response error codes over php exceptions
- works on Windows