dkkoma/php-grpc-lite
Composer 安装命令:
pie install dkkoma/php-grpc-lite
包简介
Source-built grpc extension for PHP: php-grpc-lite HTTP/2 transport drop-in candidate for ext-grpc
关键字:
README 文档
README
php-grpc-lite is a source-built PHP extension aiming to be a drop-in replacement for official ext-grpc in selected client workloads.
Current review status:
- High-level PHP
Grpc\*wrapper classes are provided by the officialgrpc/grpcComposer package. - HTTP/2 transport is provided by this repository's source-build extension at the repository root.
- The source-built grpc extension builds a PHP module named
grpcand producesgrpc.so. - Official
ext-grpcand this source-built grpc extension must not be loaded at the same time. - Runtime transport is the built-in nghttp2 HTTP/2 implementation.
- Release readiness is still gated by C extension memory/lifecycle QA.
- Unary and server streaming are the current compatibility scope. Client streaming and bidirectional streaming are not implemented yet.
Performance snapshot
Latest representative local benchmarks: 2026-05-14 for Spanner RPC shape, 2026-05-05 / 2026-05-06 for broader unary and streaming payload sweeps. Environment: Docker compose on OrbStack, Go gRPC test server, php-grpc-lite HTTP/2 transport vs official ext-grpc. These numbers are workload guidance, not a portability guarantee; rerun the benchmark suite on release hardware for final decisions. Full data: docs/benchmarks/spanner-shape-2026-05-14.md, docs/benchmarks/spanner-real-client-2026-05-14.md, docs/benchmarks/native-major-2026-05-05.md, and docs/benchmarks/native-hardening-2026-05-06.md.
| case | php-grpc-lite p50 | php-grpc-lite p99 | ext-grpc p50 | ext-grpc p99 | result |
|---|---|---|---|---|---|
| unary 100B | 28.1μs | 67.8μs | 56.6μs | 103.6μs | php-grpc-lite faster |
| unary 100KiB | 77.9μs | 2,243.1μs | 106.7μs | 1,491.2μs | p50 faster; p99 slower |
| Spanner shape: BeginTransaction unary | 31.6μs | 128.6μs | 59.2μs | 393.4μs | php-grpc-lite faster |
| Spanner shape: Commit unary | 28.2μs | 83.4μs | 54.9μs | 107.0μs | php-grpc-lite faster |
| Spanner shape: SELECT streaming | 28.9μs | 70.9μs | 62.3μs | 115.6μs | php-grpc-lite faster |
| Spanner shape: DML insert streaming | 26.1μs | 69.0μs | 68.1μs | 110.4μs | php-grpc-lite faster |
| Spanner shape: DML update streaming | 26.1μs | 72.5μs | 68.5μs | 110.3μs | php-grpc-lite faster |
| Spanner shape: DML delete streaming | 27.3μs | 65.4μs | 71.1μs | 128.9μs | php-grpc-lite faster |
| server streaming 100x100B | 135.8μs | 538.8μs | 334.1μs | 796.8μs | php-grpc-lite faster |
| server streaming 100x10KiB | 1,111.2μs | 2,255.9μs | 1,452.6μs | 1,974.3μs | p50 faster; p99 slower |
spanner-shape is the primary Spanner-oriented performance signal because it keeps the RPC shape close to Spanner while avoiding emulator and GAX noise. spanner-real-client is kept as a high-level google/cloud-spanner smoke/regression benchmark rather than a transport microbenchmark.
Large bulk streaming remains the main case that should be measured against the actual workload before choosing this extension.
Install
Install build dependencies first. Debian/Ubuntu example:
sudo apt-get install -y php-dev build-essential libnghttp2-dev libssl-dev unzip
Install the extension with PIE:
pie install dkkoma/php-grpc-lite --auto-install-build-tools --auto-install-system-dependencies
Then enable extension=grpc if PIE did not enable it automatically.
PIE uses Composer's default package download path. For this package, Composer prefers the Packagist/GitHub dist zip for the stable release. Ensure a zip extractor is available: unzip is the recommended Debian/Ubuntu package; PHP ext-zip or 7z can also satisfy Composer. Without any zip extractor, Composer falls back to source download and may require git.
Applications that use generated stubs or gax clients should also install the official PHP wrapper dependency with Composer:
composer require grpc/grpc
For local source builds without PIE:
git clone <php-grpc-lite repository URL> php-grpc-lite cd php-grpc-lite phpize ./configure --enable-grpc make -j"$(nproc)" sudo make install
Full install notes, verification commands, rollback notes, and large-streaming guidance are in docs/guides/install-native-extension.md. The documentation entrypoint is docs/README.md.
Development
Run tests in Docker:
composer install ./tools/test/check-c-static-analysis.sh ./tools/test/check-c-unit.sh ./tools/test/check-phpt.sh ./tools/test/check-crash-ub.sh ./tools/test/check-c-coverage.sh docker compose run --rm dev php -d extension=/workspace/modules/grpc.so vendor/bin/phpunit -c tests/phpunit.xml.dist
check-c-static-analysis.sh runs the C extension static analysis. check-c-unit.sh runs focused C unit tests for pure protocol helpers and status taxonomy. check-phpt.sh builds the root extension, verifies the local Go test-server ports, and runs PHPT tests for the extension surface, transport control semantics, TLS/mTLS, and resource limits. check-crash-ub.sh runs generated-input checks under ASan/UBSan to detect crashes and undefined behavior. check-c-coverage.sh runs the C unit and PHPT gates with gcov/lcov instrumentation and writes reports under var/coverage/c-lcov/. PHPUnit remains the broader integration/release compatibility suite.
GitHub Actions Native QA runs purpose-specific jobs on push and pull request: Static analysis, NTS PHPT + C coverage, ZTS PHPT, and Crash/UB check. Coverage is uploaded as a workflow artifact and to Codecov from var/coverage/c-lcov/codecov.info; configure CODECOV_TOKEN unless the Codecov repository setting allows tokenless public uploads.
Build/load the source-built grpc extension in Docker:
docker compose run --rm dev sh -lc 'phpize && ./configure --enable-grpc && make -j$(nproc)' docker compose run --rm dev php -d extension=/workspace/modules/grpc.so -r 'var_dump(extension_loaded("grpc"), defined("Grpc\\VERSION") && constant("Grpc\\VERSION") === "0.0.15");'
Verify source install on the official Docker Hub php image:
docker build -f docker/Dockerfile.install-grpc -t php-grpc-lite-install-grpc . docker run --rm php-grpc-lite-install-grpc php -m | grep -x grpc docker run --rm php-grpc-lite-install-grpc php -r 'var_dump(extension_loaded("grpc"), defined("Grpc\\VERSION") && constant("Grpc\\VERSION") === "0.0.15");'
Verify PIE install on the official Docker Hub php image:
docker build -f docker/Dockerfile.install-pie -t php-grpc-lite-install-pie . docker run --rm php-grpc-lite-install-pie php -m | grep -x grpc docker run --rm php-grpc-lite-install-pie php -r 'var_dump(extension_loaded("grpc"), defined("Grpc\\VERSION") && constant("Grpc\\VERSION") === "0.0.15");'
To verify a specific released package from Packagist:
docker build -f docker/Dockerfile.install-pie \
--build-arg PHP_GRPC_LITE_PACKAGE=dkkoma/php-grpc-lite:0.0.15 \
-t php-grpc-lite-install-pie-0.0.15 .
Design and QA status:
docs/README.mddocs/SPEC.mddocs/design/http2-transport-decision.mddocs/verification/release-qa-checklist.md
dkkoma/php-grpc-lite 适用场景与选型建议
dkkoma/php-grpc-lite 是一款 基于 C 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 05 月 08 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「pie」 「http2」 「gRPC」 「php-extension」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dkkoma/php-grpc-lite 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dkkoma/php-grpc-lite 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dkkoma/php-grpc-lite 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
RSS and Atom feed generator by Kai Blankenhorn
Simple PHP chart drawing library
jpGraph, library to make graphs and charts
Grpc PHP Client base on Swoole Http2 Coroutine
Sends Link headers to bring HTTP/2 Server Push for scripts and styles to WordPress.
This bundle provides you with an easy way to include assets on demand, but still include them in your header or footer. This can be used for your BEM blocks or facilitates HTTP2.
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 44
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2026-05-08