hub / hedera-sdk-php
Hedera Hashgraph SDK for PHP - A comprehensive PHP library for interacting with the Hedera network
Installs: 1
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/hub/hedera-sdk-php
Requires
- php: >=7.2
- ext-grpc: *
- ext-sodium: *
- google/protobuf: ^v3.12.2
- grpc/grpc: ^v1.39.0
Requires (Dev)
- ext-pcov: *
- doctrine/instantiator: ^1.5.0
- phpstan/phpstan: ^1.0
- phpunit/php-code-coverage: ^7.0.17
- phpunit/php-token-stream: ^3.1.3
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.6
This package is not auto-updated.
Last update: 2025-10-30 20:29:38 UTC
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.