protoc-gen-php --php_out: protoc-gen-php: Plugin output is unparseable.
背景
业务需要用protobuffer 进行通讯。
client: php
server: c++
在github 上找到 Protobuf-PHP (https://github.com/drslump/Protobuf-PHP) 的评分不错,故采用它作为协议生成库来生成PHP侧的交互协议。
问题
生成php proto
protoc --plugin=/usr/local/php/bin/protoc-gen-php --php_out=. -I. tutorial.proto
报错:--php_out: protoc-gen-php: Plugin output is unparseable.
proto 文件 tutorial.proto 如下:
package tutorial;
message Person {
required string name = ;
required int32 id = ;
optional string email = ;
enum PhoneType {
MOBILE = ;
HOME = ;
WORK = ;
}
message PhoneNumber {
required string number = ;
optional PhoneType type = [default = HOME];
}
repeated PhoneNumber phone = ;
}
message AddressBook {
repeated Person person = ;
}
定位与解决
PHP日志跟踪发现:
[-Apr- :: GMT] PHP Warning: Missing argument for DrSlump\Protobuf\Codec\Binary::getWireType(), called in /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php on line and defined in /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php on line
[-Apr- :: GMT] PHP Stack trace:
[-Apr- :: GMT] PHP . {main}() /usr/local/services/php-5.4./bin/protoc-gen-php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Compiler\Cli::run() /usr/local/services/php-5.4./bin/protoc-gen-php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Compiler->compile() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Compiler/Cli.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Message->__construct() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Compiler.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Message->parse() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Message.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Codec\Binary->decode() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Message.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Codec\Binary->decodeMessage() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Codec\Binary->decodeMessage() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Codec\Binary->decodeMessage() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Codec\Binary->decodeMessage() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php:
[-Apr- :: GMT] PHP . DrSlump\Protobuf\Codec\Binary->getWireType() /usr/local/services/php-5.4./lib/php/DrSlump/Protobuf/Codec/Binary.php:
跟入代码发现:/usr/local/services/php-5.4.39/lib/php/DrSlump/Protobuf/Codec/Binary.php 中的第249行,
$wire = $this->getWireType($type);
参数传递异常。
发现需要传入2个参数,于是修改为:
$wire = $this->getWireType($type, null);
重新执行
protoc-gen-php --out=./ -i. -Dsuffix=.proto.php tutorial.proto
生成成功:tutorial.proto.php
另一种方式:
protoc --plugin=/usr/local/php/bin/protoc-gen-php --php_out=. -I. tutorial.proto
生成成功:tutorial.php
协议已经成功生成。
protoc-gen-php --php_out: protoc-gen-php: Plugin output is unparseable.的更多相关文章
- protobuffer php使用
protobuffer是google推出的一种数据传的方式,具体压缩,体积小的特点 protobuffer本身不支持php,若要把.proto文件转化为php支持的文件,需要使用第三方的程序 alle ...
- Golang/Python/PHP带你彻底学会gRPC
目录 一.gRPC是什么? 二.Protocol Buffers是什么? 三.需求:开发健身房服务 四.最佳实践 Golang 1. 安装protoc工具 2. 安装protoc-gen-go 3. ...
- protoc 命令参数
protoc 命令的获得 源码在 https://github.com/google/protobuf , 如果不想自己编译获得最新版本,则可以下载官方编译好的各个平台的,下载地址:https://g ...
- PowerProto: gRPC工具链(protoc, protoc-gen-go)的一键安装与版本控制
PowerProto: gRPC工具链(protoc, protoc-gen-go)的一键安装与版本控制 中文 | English 项目地址:An awesome version control t ...
- 解析大型.NET ERP系统数据访问 对象关系映射框架LLBL Gen Pro
LLBL Gen Pro是一个为.NET开发人员设计的的对象关系映射(ORM)框架,与NHibernate,Entity Framework等框架一样,通过实体与数据表的映射,实现关系数据库持久化. ...
- Mac中体验ASP.NET 5 beta2的K gen代码生成
ASP.NET 5 beta2中增加了一个新特性(详见ASP.NET 5 Beta2 发布),可以通过K命令生成MVC的代码,比如:k gen controller -name HomeControl ...
- Tornado源码分析系列之一: 化异步为'同步'的Future和gen.coroutine
转自:http://blog.nathon.wang/2015/06/24/tornado-source-insight-01-gen/ 用Tornado也有一段时间,Tornado的文档还是比较匮乏 ...
- Erlang generic standard behaviours -- gen
在分析 gen_server (或者是gen_fsm )之前,首先应该弄明白,gen 这个module . -module(gen). -compile({inline,[get_node/1]}). ...
- Tornado中gen.coroutine详解
1.gen.coroutine的作用 自动执行生成器 2.Future对象 在介绍异步使用之前,先了解一下Future对象的作用. Future简单可以理解为一个占位符,将来会执行的对象,类似java ...
随机推荐
- StackOverflow程序员推荐的几本书籍
1. <代码大全>史蒂夫·迈克康奈尔 推荐数:1684 “优秀的编程实践的百科全书,<代码大全>注重个人技术,其中所有东西加起来,就是我们本能所说的“编写整洁的代码”.这本书有 ...
- [uboot]E9-i.MX6Q-uboot移植
参照:http://blog.csdn.net/girlkoo/article/details/45420977 文档参照: <i.MX BSP Porting Guide-2015/12, ...
- ios7 indexPathForCell 的坑(真是一个大大的坑)
笔者在编写APP 有一个功能点击cell上一个button,修改cell的在tableview中的位置 在ios8上没有问题. 在ios7上总是崩溃 以下是崩溃后提示: Terminating app ...
- 115、定时器(TimerTask+Timer+Handler)
public class TimerUtils { public static Activity act; public static List<MaiDianModels> listMa ...
- 使用input=file上传
前台,form的target指向iframe <form action="/EmailHandler.ashx?action=upload" id="form1&q ...
- [计算机取证技术] VDI-in-a-Box Analysis Results
原文跳转: http://dig4n6.blogspot.tw/2013/07/vdi-in-box-analysis-results.html *文中引用图片如无法浏览,请科学上网* VDI-in- ...
- Vs打包工程 错误: Unable to update the dependencies of the project (转)
Setup Project 错误: Unable to update the dependencies of the project 在VS2010中编译包含安装工程的解决方案提示错误:Unable ...
- ubuntu 清除缓存
2013-03-31 10:20 sudo apt-get autoremove //自动卸载不使用的内容 sudo apt-get autoclean //自动清理,但不会删除用于安装而下载的临时文 ...
- zmap使用笔记
zmap使用笔记 zmap, 一个网络端口开放性的快速扫描工具.至于这个工具的特色,配置参数,和比的工具的对比,不做介绍.只记录一下近期使用过程中,遇到的问题.软件版本:2.1.1 传言与现实 传言: ...
- CSS3属性transition
CSS3 Transitions 指定过渡 语法: transition: property duration timing-function delay; 参数一: transition-p ...