swag-industries / grpc
PHP Implementation of GRPC
Requires
- php: >= 8.4
- amphp/http-client: ^5.2
- amphp/http-server: ^3.3
- google/protobuf: ^3.25
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.87
- phpunit/phpunit: ^12.0
README
An honest attempt to make a library that runs GRPC asynchronously.
This project is currently experimental, it supports only GRPC client and has not been tested in real world.
Prerequisite
- PHP 8.4
- protobuf compiler (ubuntu:
sudo apt install protobuf-compiler
) - protobuf grpc (ubuntu:
sudo apt install protobuf-compiler-grpc
)
Installation
Install GRPC php:
composer require swag-industries/grpc
Generate your GRPC library based on the proto file:
# On macos the path to the PHP plugin may be something like this: # /opt/homebrew/Cellar/grpc/1.69.0_1/bin/grpc_php_plugin protoc --proto_path=tests/resources/protos \ --php_out=tests/protobuf \ --grpc_out=generate_server:tests/protobuf \ --plugin=protoc-gen-grpc=/usr/bin/grpc_php_plugin \ tests/resources/protos/helloworld.proto
Enjoy using the client you just generated. (usage is somehow documented on official documentation)
Note about ALTS
Google has developed its own security transport layer aside of SSL/TLS. GRPC supports ALTS. Which is the name of the custom transport layer of Google. But GRPC also supports the standard TLS.
No package in PHP can interact with ALTS. This is something extremely custom.
This is why there is currently no plan to support ALTS.
Learn more about GRPC authentication here.