PHPackages                             lvht/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. [API Development](/categories/api)
4. /
5. lvht/grpc

ActiveLibrary[API Development](/categories/api)

lvht/grpc
=========

v2.1.4(7y ago)2779612MITPHPPHP ^7

Since Jan 20Pushed 7y ago2 watchersCompare

[ Source](https://github.com/lvht/protoc-gen-grpc-php)[ Packagist](https://packagist.org/packages/lvht/grpc)[ RSS](/packages/lvht-grpc/feed)WikiDiscussions master Synced 2w ago

READMEChangelogDependencies (2)Versions (13)Used By (0)

protoc-gen-grpc-php
===================

[](#protoc-gen-grpc-php)

gRPC plugin and sdk for php.

Installation
------------

[](#installation)

```
composer require lvht/grpc

```

Generate PHP SDK
----------------

[](#generate-php-sdk)

run the following command to generate php sdk for helloworld.proto

```
protoc --php_out=out --grpc-php_out=composer_name=grpc/hello:out \
    --plugin=protoc-gen-grpc-php=./vendor/bin/protoc-gen-grpc-php \
    ./helloworld.proto

```

you will get

```
out
├── composer.json                   -- make sdk as a composer package
├── GPBMetadata
│   └── Helloworld.php
└── Helloworld
    ├── GreeterService.php          -- php interface for service
    ├── GreeterServiceTrait.php     -- generated service helper code
    ├── GreeterServiceStub.php      -- generated service stub code
    ├── HelloReply.php              -- message class generated by protoc
    └── HelloRequest.php            -- message class generated by protoc

```

For **XXX** service define in proto, you will get a `XXX` interface. The `XXX`interface has one implementation, `XXXServiceStub` for client side. And you need develop your own server side implementation using the `XXXServerTrait`.

Please see the `example/client.php` and `example/server.php` for more detail.

Arguments
---------

[](#arguments)

protoc-gen-grpc-php offer some arguments.

- composer\_name set the generated code's package name
- stub\_trait add additional trait to the generated stub
- stub\_trait\_only replace the default trait of the generated stub

Simple gRPC
-----------

[](#simple-grpc)

Besides the standard gRPC, the generated code has two additional features.

### gRPC over http/1.1

[](#grpc-over-http11)

Set the `use_http1` flag to `true` when you create a stub instance will let stub use http1.1 to transfer rpc data. Both `grpc-status` and `grpc-message` will be transfered as a normal http header instead of **Trailers**.

### simple gRPC or sRPC

[](#simple-grpc-or-srpc)

Set the `Content-Type` to `application/json` will let stub use a more simple mode to transfer rpc data. In the simple mode, only json is supported, and the message prefix must not be transfered. Both http/1 and http/2 are supported.

```
POST /helloworld.Greeter/SayHello HTTP/1.1
Accept: application/json, */*
Accept-Encoding: gzip, deflate
Connection: keep-alive
Content-Length: 24
Content-Type: application/json
Host: localhost:8080
User-Agent: HTTPie/0.9.9
foo: bar

{
    "name": "海涛"
}

HTTP/1.1 200 OK
Connection: keep-alive
Content-Length: 26
Date: Sat, 24 Feb 2018 08:09:20 GMT
Server: swoole-http-server
b-bin: 5L2g5aW9
content-type: application/json
grpc-status: 0

{
    "message": "Hello 海涛"
}

```

###  Health Score

36

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~45 days

Recently: every ~96 days

Total

11

Last Release

2632d ago

Major Versions

v1.1.2 → v2.0.02018-02-24

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/103414201?v=4)[lvht](/maintainers/lvht)[@lvht](https://github.com/lvht)

---

Top Contributors

[![optiman](https://avatars.githubusercontent.com/u/2707476?v=4)](https://github.com/optiman "optiman (2 commits)")

---

Tags

grpcgrpc-phpprotoc-grpc-plugin

### Embed Badge

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

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

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35916.4M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24016.2M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

93459.5k6](/packages/botman-driver-telegram)

PHPackages © 2026

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