drslump / Protobuf-PHP

PHP implementation of Google's Protocol Buffers with a protoc plugin compiler
http://drslump.github.com/Protobuf-PHP/
MIT License
462 stars 163 forks source link

Can not compile .proto file with protoc version 2.5. #28

Open vlinder opened 11 years ago

vlinder commented 11 years ago
$ protoc-gen-php social.proto -i `pwd`
Protobuf-PHP 0.9.4 by Ivan -DrSlump- Montes

--php_out: protoc-gen-php: Plugin output is unparseable.

ERROR: protoc exited with an error (1) when executed with: 
  protoc \
    --plugin=protoc-gen-php='/usr/local/Cellar/php54/5.4.15/bin/protoc-gen-php' \
    --proto_path='/usr/local/Cellar/php54/5.4.15/lib/php/DrSlump/Protobuf/Compiler/protos' \
    --proto_path='/Users/***/lib/model/ProtocolBuffers' \
    --php_out=':./' \
    '/Users/***/lib/model/ProtocolBuffers/social.proto'

protoc installed with brew. php54 installed with brew. protobuf-php installed with pear.

after downgrading (still using brew) to protoc 2.4.1 it compiled fine.

toannguyen commented 11 years ago

... PHP Warning: Missing argument 2 for DrSlump\Protobuf\Codec\Binary::getWireType(), called in /usr/share/pear/DrSlump/Protobuf/Codec/Binary.php on line 249 and defined in /usr/share/pear/DrSlump/Protobuf/Codec/Binary.php on line 333 PHP Warning: Missing argument 2 for DrSlump\Protobuf\Codec\Binary::getWireType(), called in /usr/share/pear/DrSlump/Protobuf/Codec/Binary.php on line 249 and defined in /usr/share/pear/DrSlump/Protobuf/Codec/Binary.php on line 333 --php_out: protoc-gen-php: Plugin output is unparseable.

FIXED: downgrading protoc 2.4.1

drslump commented 11 years ago

thanks for the report. I will investigate what changes where made to protoc since version 2.4.1, which was the version targeted when developing the library.

Nicien commented 10 years ago

Same problem here. I'm building with the svn version of protocol buffer (arm64 compatibility is recent..., I can't downgrade :(

michaliskambi commented 10 years ago

A simple fix for this is to change drslump code: DrSlump/Protobuf/Codec/Binary.php, line 249, change $wire = $this->getWireType($type); to $wire = $this->getWireType($type, null); That is because the function getWireType, defined above in the same file, really takes 2 arguments: protected function getWireType($type, $default) Some other uses of getWireType pass $default equal to null, so it seems correct. It seems 2nd argument is used only by assertWireType.

Disclaimer: I just changed it blindly and it seems to work for me. No guarantees :)