Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
A PHP Protocol Buffer Generator Plugin for protoc
C++ C PHP
branch: master

This branch is 24 commits ahead, 4 commits behind bramp:master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
.gitignore
Makefile
Protobuf.php
README.md
UnitTest.php
php_options.proto
protoc-gen-php.cc
strutil.cc
strutil.h
test.php

README.md

PHP Protocol Buffers

This is a PHP Google Protocol Buffer Generator Plugin for protoc. It generates PHP sourcecode from a .proto file. It's not finished, but supports most common features, and is currently in use in production systems.

Installation

  1. Download and install the Protocol Buffer source from http://code.google.com/p/protobuf/downloads/list
  2. Build and install the Protocol Buffer source (see instructions in source)
  3. Download this repo.
  4. cd to this repo's source and type "make".

** NOTE,

System specifics

On Debian you may need the install a few libraries with apt apt:

apt-get install libprotobuf-dev libprotobuf-lite6 libprotobuf6 libprotoc-dev libprotoc6

Usage

Once compiled you can use it via protoc like so:

protoc -I. -I/usr/include --php_out . --plugin=protoc-gen-php=./protoc-gen-php your.proto

This will generate the file "YourProto.php", which will encode and decode protocol buffer messages. When using the generated PHP code you must include the "protocolbuffers.inc.php" file.

TODO's

  • Better documentation
  • Better exception handling
  • Some kind of inheritance model to reduce generated PHP code
  • option (php_multiple_files) support.
  • option (php_package) support
  • make install to a bash wrapper so that we can do something like protocphp your.proto

Authors

Something went wrong with that request. Please try again.