2017-25 © Pedro PelÔez
 

library php-protobuf-generator

Google's protobuf generator for PHP

image

liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  • Wednesday, April 25, 2018
  • by liues1992
  • Repository
  • 1 Watchers
  • 5 Stars
  • 415 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 8 Versions
  • 8 % Grown

The README.md

, (*1)

Introduction

Generate PHP protobuf code using PHP ./protoc-gen.php -o build tests/test3.proto, (*2)

The generated message code is meant to work with Google protobuf's official PHP implementation: https://github.com/google/protobuf/tree/master/php, (*3)

The generated service client code is meant to work with gRpc https://grpc.io/docs/quickstart/php.html#prerequisites, (*4)

Requirements

  • Unix/Linux system
  • PHP >= 7.0 and composer installed
  • Only support proto3 syntax proto file
  • protoc installed, version >= 3.5

Usage

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

    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, (*6)

  • See the example folder for the generated code, (*7)

Run test

composer test, (*8)

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?

  • 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

That's a secret. Find out yourself., (*9)

The Versions

25/04 2018

dev-master

9999999-dev https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

25/04 2018

v0.1.5

0.1.5.0 https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

23/04 2018

v0.1.4

0.1.4.0 https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

07/03 2018

v0.1.3

0.1.3.0 https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

23/02 2018

v0.1.2

0.1.2.0 https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

23/01 2018

v0.1.1

0.1.1.0 https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

23/01 2018

v0.1

0.1.0.0 https://github.com/liues1992/php-protobuf-generator

Google's protobuf generator for PHP

  Sources   Download

MIT

The Requires

 

The Development Requires

protocol buffers grpc protobuf php

05/01 2018

dev-dev

dev-dev https://github.com/allegro/php-protobuf

Google's Protocol Buffers for PHP

  Sources   Download

BSD-3-Clause

The Requires

 

The Development Requires

data protocol buffers pb