i@wdeMacBook-Pro:~/Code/grpc-try/grpc/examples/php|ee5b762f33⚡ ⇒ ll
total 40drwxr-xr-x 3 i staff 96B 1116 11:11 GPBMetadata
drwxr-xr-x 5 i staff 160B 1116 11:11 Helloworld
-rw-r--r-- 1 i staff 1.0K 1116 10:42 README.md
-rw-r--r-- 1 i staff 348B 1116 10:42 composer.json
drwxr-xr-x 11 i staff 352B 1116 10:42 echo-rw-r--r-- 1 i staff 1.5K 1116 10:42 greeter_client.php
-rwxr-xr-x 1 i staff 728B 1116 10:42 greeter_proto_gen.sh
drwxr-xr-x 6 i staff 192B 1116 10:42 route_guide
-rwxr-xr-x 1 i staff 691B 1116 10:42 run_greeter_client.sh
接着执行composer install 安装相关依赖。
1
cd ../node
教程中用 node 起了一个服务端。
1
npm install
第一次安装报错,好吧。再装一次,提示我 Error: The gRPC binary module was not installed. This may be fixed by running "npm rebuild"
我 tm。。
经过各种npm install,算是装完了。然后
1
2
cd dynamic_codegen
node greeter_server.js
目测已经起来了,没有任何提示
再开一个窗口,执行
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
./run_greeter_client.sh
PHP Warning: PHP Startup: Unable to load dynamic library 'grpc.so'(tried: /usr/local/lib/php/pecl/20190902/grpc.so (dlopen(/usr/local/lib/php/pecl/20190902/grpc.so, 9): image not found), /usr/local/lib/php/pecl/20190902/grpc.so.so (dlopen(/usr/local/lib/php/pecl/20190902/grpc.so.so, 9): image not found)) in Unknown on line 0Warning: PHP Startup: Unable to load dynamic library 'grpc.so'(tried: /usr/local/lib/php/pecl/20190902/grpc.so (dlopen(/usr/local/lib/php/pecl/20190902/grpc.so, 9): image not found), /usr/local/lib/php/pecl/20190902/grpc.so.so (dlopen(/usr/local/lib/php/pecl/20190902/grpc.so.so, 9): image not found)) in Unknown on line 0PHP Fatal error: Uncaught Error: Class 'Grpc\ChannelCredentials' not found in /Users/i/Code/grpc-try/grpc/examples/php/greeter_client.php:30
Stack trace:
#0 /Users/i/Code/grpc-try/grpc/examples/php/greeter_client.php(44): greet('localhost:50051', 'world')#1 {main} thrown in /Users/i/Code/grpc-try/grpc/examples/php/greeter_client.php on line 30Fatal error: Uncaught Error: Class 'Grpc\ChannelCredentials' not found in /Users/i/Code/grpc-try/grpc/examples/php/greeter_client.php:30
Stack trace:
#0 /Users/i/Code/grpc-try/grpc/examples/php/greeter_client.php(44): greet('localhost:50051', 'world')#1 {main} thrown in /Users/i/Code/grpc-try/grpc/examples/php/greeter_client.php on line 30
./run_greeter_client.sh
PHP Warning: Module 'grpc' already loaded in Unknown on line 0Warning: Module 'grpc' already loaded in Unknown on line 0Hello world
// Copyright 2015 gRPC authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
syntax="proto3";optionjava_multiple_files=true;optionjava_package="io.grpc.examples.helloworld";optionjava_outer_classname="HelloWorldProto";optionobjc_class_prefix="HLW";packagehelloworld;// The greeting service definition.
serviceGreeter{// Sends a greeting
rpcSayHello(HelloRequest)returns(HelloReply){}}// The request message containing the user's name.
messageHelloRequest{stringname=1;}// The response message containing the greetings
messageHelloReply{stringmessage=1;}