{"id":19849334,"url":"https://github.com/52fhy/grpc-sample","last_synced_at":"2025-09-18T13:31:48.926Z","repository":{"id":84927694,"uuid":"194465560","full_name":"52fhy/grpc-sample","owner":"52fhy","description":"gRPC入坑记","archived":false,"fork":false,"pushed_at":"2019-06-30T15:42:45.000Z","size":10333,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-01T18:23:07.470Z","etag":null,"topics":["golang","grpc","php7"],"latest_commit_sha":null,"homepage":"https://www.cnblogs.com/52fhy/p/11110704.html","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/52fhy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-06-30T02:07:30.000Z","updated_at":"2024-07-06T03:37:58.000Z","dependencies_parsed_at":null,"dependency_job_id":"b6fa439a-5b21-4914-b8f6-a43a2170fe67","html_url":"https://github.com/52fhy/grpc-sample","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/52fhy/grpc-sample","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fgrpc-sample","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fgrpc-sample/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fgrpc-sample/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fgrpc-sample/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/52fhy","download_url":"https://codeload.github.com/52fhy/grpc-sample/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/52fhy%2Fgrpc-sample/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":275774134,"owners_count":25526167,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-18T02:00:09.552Z","response_time":77,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","grpc","php7"],"created_at":"2024-11-12T13:20:10.826Z","updated_at":"2025-09-18T13:31:48.900Z","avatar_url":"https://github.com/52fhy.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# grpc-sample\n\n## 入坑预警\n\n- 如果使用PHP、Python开发gRPC的客户端，需要编译gRPC命令行工具，生成proto的代码生成插件，否则proto里定义的service无法编译出来。编译需要使用GCC4.8级以上版本，否则报不支持C++11。然后需要龟速下周grpc源码，并下载一大堆第三方依赖。这个过程非常痛苦。使用golang、java的可以忽略。\n- PHP还需要按照grpc的c扩展。编译需要使用GCC4.8级以上版本。\n- 如果使用golang开发服务，依赖的第三方服务基本是下载不下来的，需要使用`go mod`增加映射规则到github仓库，github下载也是龟速。\n\n## 运行\n\n运行服务端\n\n``` go \ngo mod tidy \ngo run main.go\n```\n\n运行单元测试：\n``` go\ngo test -v client_test.go\n```\n\n运行php客户端：  \n需要先安装扩展：\n``` bash\npecl install protobuf\npecl install grpc\n\n# 记得修改php.ini文件\n\n\ncd tests\ncomposer require grpc/grpc\ncd ../\n```\n然后执行代码\n``` php \nphp tests/client_test.php\n```\n\n## 常见问题\n\n**1、CentOS6使用 go mod获取第三方依赖包unknown revision xxx错误**  \n解决：其实go mod调用链中会用到一些git指令，当git版本比较旧时，调用失败产生错误，并给出歧义的提示信息。方法就是升级git版本，CentOS6自带的git是1.7版本。升级完毕后，再尝试go mod。\n\n快速升级方法：  \ncentos6:  \n```\n# 安装yum源\nwget http://opensource.wandisco.com/centos/6/git/x86_64/wandisco-git-release-6-1.noarch.rpm \u0026\u0026 rpm -ivh wandisco-git-release-6-1.noarch.rpm\n\n## 安装git 2.x\nyum install git -y\n\n## 验证\ngit --version\ngit version 2.14.1\n```\n\n**2、PHP报错：Fatal error: Class 'Google\\Protobuf\\Internal\\Message' not found**   \n解决：请安装PHP的protobuf c扩展。  \n\n**3、PHP报错：Fatal error: Class '\\Grpc\\BaseStub' not found**   \n解决：使用`composer require grpc/grpc`安装grpc。另外对应的grpc C扩展也要安装。 \n\n**4、下载 github release包很慢怎么办?**  \n解决：下载Mac版 [`Free Download Manager` 下载工具](https://dn3.freedownloadmanager.org/5/5.1-latest/fdm.dmg)可以解决Github 下载缓慢或失败问题。速度嗖嗖的。  \n![](http://img2018.cnblogs.com/blog/663847/201906/663847-20190630182430341-213536082.png)\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F52fhy%2Fgrpc-sample","html_url":"https://awesome.ecosyste.ms/projects/github.com%2F52fhy%2Fgrpc-sample","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2F52fhy%2Fgrpc-sample/lists"}