Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Grpc Client

Grpc Client Laravel Package

spiral/grpc-client

Framework-friendly and standalone PHP gRPC client with a simple, extensible API. Configure endpoints and interceptors (timeouts, retries), integrate with Spiral/RoadRunner, and handle errors via dedicated exceptions. Requires the PHP gRPC extension.

View on GitHub
Deep Wiki
Context7

PHP client for gRPC

Frequently asked questions about Grpc Client
Can I use spiral/grpc-client in Laravel without Spiral Framework?
Yes, but you’ll need to manually wire the `GrpcClient` into Laravel’s DI container using `ServiceClientProvider`. The package is framework-agnostic and works standalone with a lightweight Guzzle-like API. For Laravel, register the provider in `config/app.php` or use a service container binding.
What Laravel versions does spiral/grpc-client support?
The package itself doesn’t enforce Laravel-specific constraints, but it requires PHP 8.1+. For Laravel integration, ensure your version supports PHP 8.1+ and manually configure the `GrpcClient` via the service provider. No direct Laravel versioning is enforced by the package.
How do I handle TLS/SSL certificates with spiral/grpc-client?
Use the `TlsConfig` class to configure certificates, keys, and CA paths. For production, store certificates securely (e.g., environment variables or a secrets manager) and rotate them via CI/CD pipelines. The package doesn’t auto-renew certificates—manual or scripted rotation is required.
Does spiral/grpc-client support bidirectional streaming?
Yes, but streaming requires careful context management. Use the generated gRPC interfaces and handle streams via callbacks or iterators. Documentation is sparse, so test thoroughly with your `.proto` schemas. For debugging, log stream states or use interceptors to validate payloads.
How do I add retry logic or timeouts to gRPC calls?
Use interceptors like `RetryInterceptor` and `SetTimeoutInterceptor`. Chain them via `withInterceptors()` in your `GrpcClient` config. Example: `$client->withInterceptors([RetryInterceptor::createConfig(3), SetTimeoutInterceptor::createConfig(5000)])`. Avoid conflicting timeouts across interceptors.
What’s the best way to manage multiple gRPC endpoints in Laravel?
Create immutable client instances per endpoint using `GrpcClient::create()` with distinct configs. For example, `$clientA = GrpcClient::create('endpointA:9001')->withInterceptors(...)` and `$clientB = GrpcClient::create('endpointB:9002')`. Store configs in Laravel’s `config/grpc.php` or environment variables.
Are there alternatives to spiral/grpc-client for Laravel?
Yes, consider `grpc/grpc` (core PHP gRPC extension) for low-level control or `symfony/grpc-client-bundle` for Symfony integration. For Laravel, `spiral/grpc-client` stands out for its Spiral/RoadRunner synergy and interceptor pipeline. If you need simpler REST-like gRPC, evaluate `grpc/grpc` directly with generated stubs.
How do I generate PHP interfaces from .proto files for this package?
Use `protoc` with the `protoc-gen-php-grpc` plugin. Run `protoc --php_out=. --grpc_out=. --plugin=protoc-gen-grpc=grpc_php_plugin your_service.proto`. Place generated files in `app/Grpc` or a similar namespace. The package expects interfaces to match the `.proto` service definitions exactly.
Can I use spiral/grpc-client in Laravel with RoadRunner?
Indirectly, yes. While the package isn’t Laravel-native, it integrates with Spiral’s `roadrunner-bridge`. For Laravel, use RoadRunner as a worker pool and instantiate `GrpcClient` in your Laravel app, then pass it to RoadRunner workers via shared memory or environment variables. Avoid direct RoadRunner bootloader usage.
How do I test gRPC clients in Laravel’s PHPUnit?
Mock gRPC services using PHPUnit’s `getMockBuilder()` or libraries like `Mockery`. Replace the `GrpcClient` with a mock in tests, verifying calls to `service()` and method invocations. For integration tests, use a local gRPC server (e.g., Dockerized) and assert responses. Avoid testing interceptors in unit tests unless they have side effects.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codraw/framework-extra-bundle
codraw/messenger
codraw/security
codraw/mailer
codraw/contracts
codraw/profiling
codraw/dependency-injection
codraw/tester
codraw/core
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony