Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ltd-beget/php-grpc-client-generator
https://github.com/ltd-beget/php-grpc-client-generator
grpc php protobuf
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/ltd-beget/php-grpc-client-generator
- Owner: LTD-Beget
- Created: 2017-03-02T22:45:19.000Z (almost 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-03T12:35:46.000Z (over 6 years ago)
- Last Synced: 2023-09-20T07:21:18.133Z (over 1 year ago)
- Topics: grpc, php, protobuf
- Language: PHP
- Size: 22.5 KB
- Stars: 4
- Watchers: 23
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Php GRPC client generator
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;
```