PHPackages                             liues1992/php-protobuf-generator - 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. liues1992/php-protobuf-generator

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

liues1992/php-protobuf-generator
================================

Google's protobuf generator for PHP

v0.1.7(7y ago)1112.6k↑275%12MITPHPPHP &gt;=7.0

Since Jan 5Pushed 7y ago1 watchersCompare

[ Source](https://github.com/liues1992/php-protobuf-generator)[ Packagist](https://packagist.org/packages/liues1992/php-protobuf-generator)[ Docs](https://github.com/liues1992/php-protobuf-generator)[ RSS](/packages/liues1992-php-protobuf-generator/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (10)Used By (2)

[![](https://camo.githubusercontent.com/ac8f294a80f65338db545230f1a881b9a382204a1f187c6ff40ee679d42d40ca/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c696e6b2d3939362e6963752d7265642e737667)](https://996.icu)

Introduction
============

[](#introduction)

Generate PHP protobuf code using PHP `./protoc-gen.php -o build tests/test3.proto`

The generated message code is meant to work with Google protobuf's official PHP implementation:

The generated service client code is meant to work with gRpc

Requirements
============

[](#requirements)

- Unix/Linux system
- PHP &gt;= 7.0 and composer installed
- Only support proto3 syntax proto file
- protoc installed, version &gt;= 3.5

Usage
=====

[](#usage)

- `composer require liues1992/php-protobuf-generator`
- `./vendor/bin/protoc-gen.php --out=build --grpc_out=build tests/*.proto` or use directly as plugin:

    `protoc --php-custom_out=build --plugin=protoc-gen-php-custom=./vendor/bin/protoc-gen-plugin.php \ --grpc-php_out=build --plugin=protoc-gen-grpc-php=./vendor/bin/protoc-gen-grpc-plugin.php tests/*.proto`
- See the [example](./example) folder for the generated code

### Run test

[](#run-test)

`composer test`

TODO
====

[](#todo)

- More test case
- Pack to phar
- Support proto2
- Custom generator support (write your own code generators by require this package)

Why do I need this instead of Google's default implementation?
==============================================================

[](#why-do-i-need-this-instead-of-googles-default-implementation)

- Sometimes you wish to customize the generated code, which is complicated to do if you modify google/protobuf source code(c++) and recompile the protoc binary. Think about above situations:
    - Add convenience methods in message class..
    - Support proto2
    - Generate custom rpc code (if you are not using gRpc or you want it to use in PHP server side)
- Some bug in Google's generated code.

```
    public function setEnum($var)
    {
        // GPBUtil::checkEnum accepts only on param
        GPBUtil::checkEnum($var, \Gary\Test\Foo_Enum::class);
        $this->enum = $var;

        return $this;
    }

```

- Cool to generate PHP code using PHP (easy for PHP developers to join).

How does it work
================

[](#how-does-it-work)

That's a secret. Find out yourself.

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity32

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 67.7% 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 ~69 days

Total

8

Last Release

2716d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/551295764a651eb89bcbee97ee859fc6a2f131fb4e61a94a397c3290fb8e55ff?d=identicon)[liues1992](/maintainers/liues1992)

---

Top Contributors

[![furrych](https://avatars.githubusercontent.com/u/127220829?v=4)](https://github.com/furrych "furrych (21 commits)")[![liues1992](https://avatars.githubusercontent.com/u/1286159?v=4)](https://github.com/liues1992 "liues1992 (10 commits)")

---

Tags

phpphp-protobufgRPCprotocol buffersprotobuf php

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/liues1992-php-protobuf-generator/health.svg)

```
[![Health](https://phpackages.com/badges/liues1992-php-protobuf-generator/health.svg)](https://phpackages.com/packages/liues1992-php-protobuf-generator)
```

###  Alternatives

[protocolbuffers/protoc-gen-php

protoc generator plugin for PECL ProtocolBuffers

529.1k](/packages/protocolbuffers-protoc-gen-php)

PHPackages © 2026

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