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)2779512MITPHPPHP ^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 5d 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

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity70

Established project with proven stability

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

2587d ago

Major Versions

v1.1.2 → v2.0.02018-02-24

### Community

Maintainers

![](https://www.gravatar.com/avatar/88784a5e09bb664bce6c25a861dcf8207df61c3ac6c13805f33dc126a80e91c7?d=identicon)[lvht](/maintainers/lvht)

---

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

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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