This is a simple demo, used to demonstrate how to use PHP as a gRPC service.
When these installations encounter problems, please refer to: https://grpc.io/docs/quickstart/php.html
git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
cd grpc
git submodule update --init
make
sudo make install
git clone -b $(curl -L https://grpc.io/release) https://github.com/grpc/grpc
cd grpc
git submodule update --init
make grpc_php_plugin
pecl install protobuf
pecl install ext-grpc
composer install
protoc --php_out=./pb-src --grpc_out=./pb-src --plugin=protoc-gen-grpc=$(which grpc_php_plugin) ./protos/HelloWorld.proto
require_once __DIR__.'/vendor/autoload.php';
$server = new \Dev\Fyn\Server('0.0.0.0:50051');
$server->serve();
require_once __DIR__.'/vendor/autoload.php';
$client = new HelloWorldClient('127.0.0.1:50051',[
'credentials'=>\Grpc\ChannelCredentials::createInsecure()
]);
$request = new SayHelloRequest();
$request->setName('fyn');
$call = $client->SayHello($request);
[$response, $status] = $call->wait();
echo "Code: ", $status->code,"\n";
echo "Details: ", $status->details,"\n";
echo "Reply: ", ($response?$response->getReply():null),"\n";