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

Source: Internet
Author: User
Tags stack trace

Background

The business needs to communicate with Protobuffer.

client:php

Server:c++

Finding protobuf-php (Https://github.com/drslump/Protobuf-PHP) on GitHub is good, so use it as a protocol generation repository to generate PHP-side interactive protocols.

Problem

Generate PHP Proto

Protoc--plugin=/usr/local/php/bin/protoc-gen-php--php_out=. -I. Tutorial.proto

Error:--php_out:protoc-gen-php:plugin output is unparseable.

The proto file Tutorial.proto is as follows:

Package tutorial;message Person {requiredstringName =1; Required Int32 ID=2; Optionalstringemail =3; enumPhonetype {MOBILE=0; HOME=1; work=2; } message PhoneNumber {requiredstringNumber =1; Optional Phonetype type=2[default=HOME]; } Repeated PhoneNumber phone=4; } Message AddressBook {repeated person person=1; }

Positioning and resolution

PHP Log Trace discovery:

[ --apr- -  the: -: -GMT] PHP warning:missing argument2  forDrslump\protobuf\codec\binary::getwiretype (), calledinch/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php on line249and definedinch/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php on line333[ --apr- -  the: -: -GMT] PHP Stack trace:[ --apr- -  the: -: -GMT] PHP1. {main} ()/usr/local/services/php-5.4. the/bin/protoc-gen-php:0[ --apr- -  the: -: -GMT] PHP2. Drslump\protobuf\compiler\cli::run ()/usr/local/services/php-5.4. the/bin/protoc-gen-php: +[ --apr- -  the: -: -GMT] PHP3. Drslump\protobuf\compiler->compile ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/compiler/cli.php: -[ --apr- -  the: -: -GMT] PHP4. Drslump\protobuf\message->__construct ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/compiler.php:104[ --apr- -  the: -: -GMT] PHP5. Drslump\protobuf\message->parse ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/message.php: About[ --apr- -  the: -: -GMT] PHP6. Drslump\protobuf\codec\binary->decode ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/message.php:107[ --apr- -  the: -: -GMT] PHP7. Drslump\protobuf\codec\binary->decodemessage ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php: $[ --apr- -  the: -: -GMT] PHP8. Drslump\protobuf\codec\binary->decodemessage ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php:266[ --apr- -  the: -: -GMT] PHP9. Drslump\protobuf\codec\binary->decodemessage ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php:266[ --apr- -  the: -: -GMT] PHPTen. Drslump\protobuf\codec\binary->decodemessage ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php:266[ --apr- -  the: -: -GMT] PHP One. Drslump\protobuf\codec\binary->getwiretype ()/usr/local/services/php-5.4. the/lib/php/drslump/protobuf/codec/binary.php:249

Follow Code discovery: Line No. 249 in/usr/local/services/php-5.4.39/lib/php/drslump/protobuf/codec/binary.php,

$wire = $this->getwiretype ($type);

Parameter pass exception.

The discovery requires 2 parameters to be passed and is then modified to:

null);

Re-execute

protoc-gen-php--out=./-I.-dsuffix=.proto.php Tutorial.proto

Build success: tutorial.proto.php

Another way:

Protoc--plugin=/usr/local/php/bin/protoc-gen-php--php_out=. -I. Tutorial.proto

Build success: tutorial.php

The protocol has been successfully generated.

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.