PHPackages                             bsn4/grpc - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. bsn4/grpc

ActivePhp-ext[Utility &amp; Helpers](/categories/utility)

bsn4/grpc
=========

Rust-based gRPC extension for PHP — drop-in replacement for ext-grpc

v0.2.1(1mo ago)2393↓41.7%2MITRustPHP &gt;=8.2CI passing

Since Mar 4Pushed 1mo agoCompare

[ Source](https://github.com/BSN4/grpc-php-rs)[ Packagist](https://packagist.org/packages/bsn4/grpc)[ Docs](https://github.com/BSN4/grpc-php-rs)[ RSS](/packages/bsn4-grpc/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (10)DependenciesVersions (13)Used By (0)

grpc-php-rs
===========

[](#grpc-php-rs)

[![CI](https://github.com/BSN4/grpc-php-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/BSN4/grpc-php-rs/actions/workflows/ci.yml)[![PIE](https://camo.githubusercontent.com/691d13bc4906391fb74345b7e7546e5686c05c297ceddc83301edd15f3ebaa82/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5049452d62736e34253246677270632d626c7565)](https://packagist.org/packages/bsn4/grpc)[![PHP](https://camo.githubusercontent.com/45cd56d9263d87e8f4fe8fdf9b155e3909b5fe36c0100558315e5767da404f58/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e322532422d383839324246)](https://www.php.net)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)

A Rust-based gRPC extension for PHP — **drop-in replacement** for the official `ext-grpc`.

Why?
----

[](#why)

The official C-based `grpc` extension has long-standing issues:

- **ZTS/TSRM crashes** — segfaults under FrankenPHP, Swoole, and other threaded SAPIs
- **OpenSSL/BoringSSL conflicts** — the bundled BoringSSL collides with PHP's OpenSSL, breaking `ext-curl` and other extensions

grpc-php-rs solves both by using a pure Rust stack: [tonic](https://github.com/hyperium/tonic) for gRPC, [rustls](https://github.com/rustls/rustls) for TLS (no OpenSSL), and [ext-php-rs](https://github.com/davidcole1340/ext-php-rs) for PHP bindings.

Install
-------

[](#install)

### Docker (recommended)

[](#docker-recommended)

One line in your Dockerfile — no build tools needed:

```
FROM php:8.5-cli

COPY --from=ghcr.io/bsn4/grpc-php-rs:latest-php8.5 /usr/local/ /usr/local/
```

For ZTS (FrankenPHP, Swoole, etc.):

```
COPY --from=ghcr.io/bsn4/grpc-php-rs:latest-php8.5-zts /usr/local/ /usr/local/
```

Available tags: `latest-php8.2`, `latest-php8.3`, `latest-php8.4`, `latest-php8.5` (add `-zts` for thread-safe). Version-pinned tags like `v0.1.2-php8.5` are also available.

### Via PIE

[](#via-pie)

```
pie install bsn4/grpc
```

> **Note:** Requires PIE 1.4.0+ (pre-packaged binary support). PIE 1.3.x will fail.

In Docker (when PIE 1.4.0 stable isn't available yet):

```
RUN apt-get update && apt-get install -y --no-install-recommends curl unzip git \
    && git clone --branch 1.4.x --depth 1 https://github.com/php/pie.git /tmp/pie \
    && curl -sLo /usr/local/bin/composer https://getcomposer.org/download/latest-stable/composer.phar \
    && chmod +x /usr/local/bin/composer \
    && cd /tmp/pie && composer install --no-dev --quiet \
    && /tmp/pie/bin/pie install bsn4/grpc \
    && rm -rf /tmp/pie /usr/local/bin/composer \
    && apt-get purge -y git unzip \
    && apt-get autoremove -y \
    && rm -rf /var/lib/apt/lists/*
```

### Manual download

[](#manual-download)

Download the appropriate `.so` from the [latest release](https://github.com/BSN4/grpc-php-rs/releases/latest), then:

```
# Copy to your PHP extensions directory
cp grpc.so $(php -r "echo ini_get('extension_dir');")

# Enable it
echo "extension=grpc" > $(php -r "echo PHP_CONFIG_FILE_SCAN_DIR;")/grpc.ini
```

Supported Platforms
-------------------

[](#supported-platforms)

PHPOSArchThread Safety8.2, 8.3, 8.4, 8.5Linuxx86\_64NTS, ZTS8.2, 8.3, 8.4, 8.5LinuxARM64NTS, ZTS8.2, 8.3, 8.4, 8.5macOSARM64NTS8.2, 8.3, 8.4, 8.5Windowsx86\_64NTSUsage
-----

[](#usage)

grpc-php-rs is a drop-in replacement. Add to your `php.ini`:

```
extension=grpc
```

Then use the `Grpc\` namespace as normal:

```
$channel = new \Grpc\Channel('localhost:50051', [
    'credentials' => \Grpc\ChannelCredentials::createInsecure(),
]);
```

All existing gRPC PHP code works unchanged — `Grpc\Channel`, `Grpc\ChannelCredentials`, `Grpc\CallCredentials`, `Grpc\Timeval`, and all call types (`UnaryCall`, `ServerStreamingCall`, `ClientStreamingCall`, `BidiStreamingCall`).

Building from Source
--------------------

[](#building-from-source)

Requirements:

- Rust toolchain (stable; nightly required on Windows)
- PHP 8.2+ development headers (`php-dev` / `php-devel`)

```
cargo build --release
# Output: target/release/libgrpc_php_rs.so (Linux) or libgrpc_php_rs.dylib (macOS) or grpc_php_rs.dll (Windows)
```

Running Tests
-------------

[](#running-tests)

```
./test.sh all       # Build Docker images + run smoke & compatibility tests
./test.sh zts       # ZTS stress test with FrankenPHP + concurrent requests
./test.sh smoke     # PHP smoke test only
./test.sh shell     # Drop into PHP CLI with extension loaded
```

See `./test.sh --help` for all options.

License
-------

[](#license)

MIT

###  Health Score

44

—

FairBetter than 92% of packages

Maintenance90

Actively maintained with recent releases

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.3% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

12

Last Release

47d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/255cea9e30c461b3d147b29347066d5e280d5d4c378232df039cb535f9c5e6fe?d=identicon)[bsn4](/maintainers/bsn4)

---

Top Contributors

[![BSN4](https://avatars.githubusercontent.com/u/199647?v=4)](https://github.com/BSN4 "BSN4 (28 commits)")[![dkkoma](https://avatars.githubusercontent.com/u/1209568?v=4)](https://github.com/dkkoma "dkkoma (1 commits)")[![keithbrink](https://avatars.githubusercontent.com/u/15267205?v=4)](https://github.com/keithbrink "keithbrink (1 commits)")

---

Tags

frankenphpgrpcphpphp-extensionrustrustlstoniczts

### Embed Badge

![Health badge](/badges/bsn4-grpc/health.svg)

```
[![Health](https://phpackages.com/badges/bsn4-grpc/health.svg)](https://phpackages.com/packages/bsn4-grpc)
```

###  Alternatives

[zuweie/field-interaction

make the laravel-admin field has a interaction

1076.6k](/packages/zuweie-field-interaction)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
