hub/hedera-sdk-php
最新稳定版本:v1.2
Composer 安装命令:
composer require hub/hedera-sdk-php
包简介
Hedera Hashgraph SDK for PHP - A comprehensive PHP library for interacting with the Hedera network
README 文档
README
Rationale
GRPC php bindings for hedera API. Compatible with php7.2+ (until 8.1 at least).
Process
- Install or build protocol buffers compiler (
protoc) with php plugins. Instructions from https://grpc.io/docs/languages/php/quickstart/
git clone --recurse-submodules -b v1.75.1 --depth 1 --shallow-submodules https://github.com/grpc/grpc bazel build @com_google_protobuf//:protoc //src/compiler:all v1.75.1 # bazel does not work with 1.40 #git clone --recurse-submodules -b v1.40.0 --depth 1 --shallow-submodules https://github.com/grpc/grpc #bazel build @com_google_protobuf//:protoc //src/compiler:all v1.40.0
- Clone protocol buffers specs from official hedera repo.
git clone https://github.com/hashgraph/hedera-protobufs/releases/tag/v0.62.4
- Generate php stubs for desired protocol buffers packages.
protoc --descriptor_set_out=out.protoset --include_imports --proto_path=./services --proto_path=./platform services/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./mirror --proto_path=./platform --php_out=../hedera-php/Generatedmirror2 --grpc_out=../hedera-php/Generatedmirror2 --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary mirror/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./platform --proto_path=./platform/event --proto_path=./platform/state --php_out=../hedera-php/Generated --grpc_out=../hedera-php/Generated --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary services/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./platform --proto_path=./platform/event --proto_path=./platform/state --php_out=../hedera-php/Generatedplatformevent --grpc_out=../hedera-php/Generatedplatformevent --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary platform/event/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./platform --proto_path=./platform/event --proto_path=./platform/state --php_out=../hedera-php/Generatedauxiliaryhints --grpc_out=../hedera-php/Generatedauxiliaryhints --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary services/auxiliary/hints/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./platform --proto_path=./platform/event --proto_path=./platform/state --php_out=../hedera-php/Generatedstatehints --grpc_out=../hedera-php/Generatedstatehints --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary services/state/hints/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./platform --proto_path=./platform/event --proto_path=./platform/state --php_out=../hedera-php/Generatedauxiliaryhistory --grpc_out=../hedera-php/Generatedauxiliaryhistory --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary services/auxiliary/history/*.proto ../grpc/bazel-bin/external/com_google_protobuf/protoc --descriptor_set_out=out.protoset --include_imports --proto_path=../grpc/third_party/protobuf/src/ --proto_path=./services --proto_path=./platform --proto_path=./platform/state --php_out=../hedera-php/Generatedstatehistory --grpc_out=../hedera-php/Generatedstatehistory --plugin=protoc-gen-grpc=../grpc/bazel-bin/src/compiler/grpc_php_plugin_binary services/state/history/*.proto
-
Build higher-level wrappers around the raw clients.
-
Build required grpc extensions.
# PECL setup for debian-based systems apt install php-dev php-pear composer pecl install grpc-1.76.0 # Config for php v 8.1 echo -e "; configuration for php grpc module\n; priority=20\nextension=grpc.so\n" > /etc/php/8.1/mods-available/grpc.ini ln -s /etc/php/8.1/mods-available/grpc.ini /etc/php/8.1/cli/conf.d/20-grpc.ini
Improvements
- increase tests coverage.
- exhaustive features integrations (basically, only HCS is integrated now).
- separate mirror client from main client and avoid namespace clash between "ConsensusService".
- Transform precheck codes enums to more user friendly messages.
- More flexible interface to customize any internal parameter, inspired from other non-PHP SDKs like https://github.com/hiero-ledger/hiero-sdk-js.
- Expose internal types/messages or build a more friendly wrapper around them (eg: handle topicId like strings and parse internally into realm, shard and num).
- Include hbar to tinybar utilities and arbitrary precision operations.
- Autodetect node number from node host or viceversa by using AddressBooks.
- Autodetect account number from public key or viceversa.
- Allow to perform EVM compatible operations.
- Improve fee handling and trx payment.
- Support EVM compatible layer (ECDSA encryption would be needed then).
- Integrate with mirror JSON-RPC interfaces for old transactions.
统计信息
- 总下载量: 9
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-10-29