承接 srwiez/grpc-protoset 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

srwiez/grpc-protoset

最新稳定版本:v1.0.0

Composer 安装命令:

composer require srwiez/grpc-protoset

包简介

Convert a protoset file to a directory of .proto files

README 文档

README

Latest Stable Version Total Downloads License PHP Version Require

A simple PHP library to convert a protoset file to proto files.

If you're here, you likely attempted to use a gRPC API and need to generate a PHP client. However, you may be stuck because you have a protoset file instead of a proto file.

This library will assist you in converting the protoset file to proto files.

It works well with gRPC servers that have the reflection service enabled. To learn more, check out the use case example below.

🚀 Installation

composer require srwiez/grpc-protoset

📚 Usage

Either use the ProtosetConverter class directly.

use SRWieZ\GrpcProtoset\ProtosetConverter;

$protoset = new ProtosetConverter();
$protoset->setOutputDir('./proto');
$protoset->convert('starlink.protoset');

or use the script provided by the package.

php cli/converter.php "starlink.protoset" ./proto

or if you have installed the package globally, you can use the following command:

protoset-converter "starlink.protoset" ./proto

🎁 Use case example (Starlink)

How to generate a PHP client for the Starlink API.

You will need to install the following dependencies:

brew install protobuf
brew install grpc
brew install grpcurl

First, get the protoset file from your Starlink device.

grpcurl -plaintext -protoset-out "starlink.protoset" "192.168.100.1:9200" describe SpaceX.API.Device.Device

Then, convert the protoset file to proto files.

protoset-converter "starlink.protoset" ./proto

Finally, generate the PHP client.

protoc --php_out=./generated/ proto/spacex/api/device/device.proto

Bonus, edit your composer.json file to autoload the generated PHP client.

{
    "autoload": {
        "psr-4": {
          "SpaceX\\API\\": "generated/SpaceX/API",
          "GPBMetadata\\Spacex\\Api\\": "generated/GPBMetadata/Spacex/Api"
        }
    }
}

📋 TODO

Contributions are welcome!

  • Write tests by using the starlink protoset file

🤝 Contributing

Clone the project and run composer update to install the dependencies.

Before pushing your changes, run composer qa.

This will run pint (code style), phpstan (static analysis), and pest (tests).

👥 Credits

gRPC Protoset Converter was created by Eser DENIZ.

The following projects inspired this library and served as a reference:

📝 License

gRPC Protoset Converter is licensed under the MIT License. See LICENSE for more information.

统计信息

  • 总下载量: 336
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 0
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-11-24