1<?php 2/* 3 * 4 * Copyright 2018 gRPC authors. 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 * 18 */ 19 20require dirname(__FILE__).'/vendor/autoload.php'; 21 22$client = new Grpc\Gateway\Testing\EchoServiceClient('node-server:9090', [ 23 'credentials' => Grpc\ChannelCredentials::createInsecure(), 24]); 25 26 27// unary call 28$request = new Grpc\Gateway\Testing\EchoRequest(); 29$request->setMessage("Hello World!"); 30 31list($response, $status) = $client->Echo($request)->wait(); 32 33echo $response->getMessage()."\n"; 34 35 36// server streaming call 37$stream_request = new Grpc\Gateway\Testing\ServerStreamingEchoRequest(); 38$stream_request->setMessage("stream message"); 39$stream_request->setMessageCount(5); 40 41$responses = $client->ServerStreamingEcho($stream_request)->responses(); 42 43foreach ($responses as $response) { 44 echo $response->getMessage()."\n"; 45} 46