1. Go to this page and download the library: Download spiral/grpc-client library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
spiral / grpc-client example snippets
use Spiral\Grpc\Client\GrpcClient;
// Minimal — one endpoint, call service methods right away
$client = GrpcClient::create('localhost:9001');
$mailSender = $client->service(\GRPC\MyService\MailSenderInterface::class);
$mailSender->sendMail($ctx, $request);
use Spiral\Grpc\Client\GrpcClient;
use Spiral\Grpc\Client\Interceptor\SetTimeoutInterceptor;
use Spiral\Grpc\Client\Interceptor\RetryInterceptor;
$client = GrpcClient::create('localhost:9001')
->withInterceptors([
SetTimeoutInterceptor::createConfig(10_000),
RetryInterceptor::createConfig(maximumAttempts: 3),
]);
use Spiral\Grpc\Client\Config\ConnectionConfig;
use Spiral\Grpc\Client\Config\TlsConfig;
$client = GrpcClient::create(
new ConnectionConfig('localhost:9001', tls: new TlsConfig(
certChain: '/my-project.pem',
privateKey: '/my-project.key',
)),
);