-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update grpc verson to v1.60.1 and add grpc php tools
- Loading branch information
Showing
23 changed files
with
1,630 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# mac protoc安装 | ||
protocExec=`which protoc` | ||
if [ ! -z $phpExec ]; then | ||
echo "you has installed protoc" | ||
exit 0 | ||
fi | ||
|
||
brew install autoconf | ||
brew install automake | ||
brew install libtool | ||
brew install curl | ||
brew install make | ||
brew install g++ | ||
brew install unzip | ||
brew install cmake | ||
brew install protobuf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# mac protobuf安装 | ||
```shell | ||
brew install protobuf | ||
``` | ||
或者编译安装: | ||
```shell | ||
git clone https://github.com/google/protobuf.git | ||
cd protobuf | ||
sh ./autogen.sh | ||
./configure | ||
make | ||
sudo make install | ||
``` | ||
# php grpc_php_plugin 插件安装 | ||
参考文档:https://www.jianshu.com/p/bb15ad7532be | ||
|
||
```shell | ||
make protoc grpc_php_plugin | ||
``` | ||
|
||
# php protobuf拓展安装 | ||
先判断是否安装php grpc.so and protobuf.so | ||
```shell | ||
php -m | grep proto | ||
php -m | grep grpc | ||
``` | ||
如果没有任何输出就需要安装grpc和protobuf拓展 | ||
```shell | ||
pecl install grpc | ||
pecl install protobuf | ||
``` | ||
安装grpc拓展成功提示(这里我是php8.1版本): | ||
``` | ||
Build process completed successfully | ||
Installing '/usr/local/Cellar/[email protected]/8.1.25/pecl/20210902/grpc.so' | ||
install ok: channel://pecl.php.net/grpc-1.59.1 | ||
Extension grpc enabled in php.ini | ||
``` | ||
|
||
安装protobuf拓展成功提示: | ||
``` | ||
Build process completed successfully | ||
Installing '/usr/local/Cellar/[email protected]/8.1.25/pecl/20210902/protobuf.so' | ||
install ok: channel://pecl.php.net/protobuf-3.25.1 | ||
Extension protobuf enabled in php.ini | ||
``` | ||
|
||
查看php.ini路径目录 | ||
```shell | ||
php --ini | ||
``` | ||
将输出如下内容: | ||
``` | ||
% php --ini | ||
Configuration File (php.ini) Path: /usr/local/etc/php/8.1 | ||
Loaded Configuration File: /usr/local/etc/php/8.1/php.ini | ||
Scan for additional .ini files in: /usr/local/etc/php/8.1/conf.d | ||
Additional .ini files parsed: /usr/local/etc/php/8.1/conf.d/ext-opcache.ini | ||
``` | ||
|
||
安装好后,在php.ini中添加对应的配置即可 | ||
(一般来说上面安装后,会自动添加依赖,如果没有添加,请手动添加即可) | ||
```ini | ||
extension=protobuf.so | ||
extension=grpc.so | ||
``` | ||
查看拓展是否安装成功: | ||
```shell | ||
php -m | grep grpc | ||
php -m | grep protobuf | ||
``` | ||
|
||
# php composer安装 | ||
```shell | ||
cd ~ | ||
php -r "copy('https://install.phpcomposer.com/installer', 'composer-setup.php');" | ||
php composer-setup.php | ||
php -r "unlink('composer-setup.php');" | ||
``` | ||
将安装好的composer.phar移动到/usr/local/bin/下面即可 | ||
```shell | ||
sudo mv composer.phar /usr/local/bin/composer | ||
``` | ||
设置镜像: | ||
```shell | ||
composer config -g repo.packagist composer https://packagist.org | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# php grpc工具安装 | ||
# grpc_php_plugin check. | ||
grpc_php_plugin=$(which "grpc_php_plugin") | ||
if [ -z $grpc_php_plugin ]; then | ||
mkdir ~/web/ | ||
cd ~/web | ||
git clone -b v1.60.0 https://github.com/grpc/grpc | ||
cd ~/web/grpc | ||
git checkout -b v1 | ||
git submodule update --init --recursive | ||
mkdir -p cmake/build | ||
cd cmake/build | ||
cmake ../.. | ||
make | ||
make grpc_php_plugin | ||
make protoc grpc_php_plugin | ||
cp grpc_php_plugin /usr/local/bin/ | ||
chmod +x /usr/local/bin/grpc_php_plugin | ||
|
||
# 安装php grpc拓展(推荐pecl方式安装) | ||
# pecl install grpc | ||
# 安装完成后,修改php.ini文件,增加配置 extension = grpc.so | ||
else | ||
echo "grpc_php_plugin exists!" | ||
fi | ||
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# mac 源码安装protoc,当然你可以使用 mac-install-grpc.sh 快速安装 | ||
protoExec=$(which "protoc") | ||
if [ -z $protoExec ]; then | ||
mkdir ~/web/ | ||
cd ~/web/ | ||
git clone https://github.com/google/protobuf.git | ||
cd protobuf | ||
sh ./autogen.sh | ||
./configure | ||
make | ||
sudo make install | ||
fi | ||
|
||
# centos7 安装参考地址 https://github.com/daheige/rs-rpc?tab=readme-ov-file#centos7-install-protoc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
{ | ||
"dependencies": { | ||
"google-protobuf": "^3.20.1", | ||
"grpc": "^1.24.11", | ||
"grpc-tools": "^1.11.2" | ||
"google-protobuf": "^3.21.2", | ||
"@grpc/grpc-js": "^1.9.11", | ||
"grpc-tools": "^1.12.4" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.