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.
- Download and install the Protocol Buffer source from http://code.google.com/p/protobuf/downloads/list
- Build and install the Protocol Buffer source (see instructions in source)
- Download this repo.
cd
to this repo's source and type "make".
** NOTE,
On Debian you may need the install a few libraries with apt apt:
apt-get install libprotobuf-dev libprotobuf-lite6 libprotobuf6 libprotoc-dev libprotoc6
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.
- 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 likeprotocphp your.proto
- Original source by Andrew Brampton (c) 2010 http://github.com/bramp/protoc-gen-php
- This fork updates by Jeffrey Sambells