ltd-beget / php-grpc-client-generator
Generate grpc client classes after protoc-gen-php
Installs: 7 622
Dependents: 0
Suggesters: 0
Security: 0
Stars: 4
Watchers: 23
Forks: 1
Open Issues: 0
Requires
- php: >=5.4.0
- grpc/grpc: v1.2.0
- nikic/php-parser: ^4.0.0
This package is auto-updated.
Last update: 2024-10-17 02:17:07 UTC
README
This util generate wrappers for client classes generated by protoc-gen-php
.
Proto file example
syntax = "proto3";
package beget.hello;
service Greeter {
rpc SayHello (HelloRequest) returns (HelloReply) {}
}
message HelloRequest {
string name = 1;
}
message HelloReply {
string message = 1;
}
Usage
protoc-gen-php -Dmultifile -i ../protos/ -o . ../protos/hello.proto
ini_set('xdebug.max_nesting_level', 3000);
use LTDBeget\util\PhpGrpcClientGenerator\PhpGenerator;
(new PhpGenerator())
->setInputPath(__DIR__ . '/proto')
->setOutputPath(__DIR__)
->run();
require __DIR__ . '/vendor/autoload.php';
$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;