PHP code example of ltd-beget / php-grpc-client-generator

1. Go to this page and download the library: Download ltd-beget/php-grpc-client-generator 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/ */

    

ltd-beget / php-grpc-client-generator example snippets


ini_set('xdebug.max_nesting_level', 3000);

use LTDBeget\util\PhpGrpcClientGenerator\PhpGenerator;

(new PhpGenerator())
    ->setInputPath(__DIR__ . '/proto')
    ->setOutputPath(__DIR__)
    ->run();




$client = new \beget\hello\GreeterClientSimple(
    new \beget\hello\GreeterClient(
        'localhost:50051',
        [
            'credentials' => Grpc\ChannelCredentials::createInsecure(),
        ]
    )
);

$request = new \beget\hello\HelloRequest();
$request->setName(time());

$reply = $client->SayHello($request);

echo $reply->getMessage(), PHP_EOL;