如何在PHP中处理Protocol Buffers数据
来源:才华咖 本文已影响2.24W人
来源:才华咖 本文已影响2.24W人
Protocol Buffers是Google定义的一种跨语言、跨平台、可扩展的数据传输及存储的协议,因为将字段协议分别放在传输两端,传输数据中只包含数据本身,不需要包含字段说明,所以传输数据量小,解析效率高。如何在PHP中处理Protocol Buffers数据呢?下面小编为大家解答一下,希望能帮到您!
如果想在PHP中使用Protocol Buffers,需要借助于第三方的扩展,使用方法如下。
安装protoc编译器
第一步,安装Google的protoc编译器,这个工具可以把proto文件中定义的Message转换为各种编程语言中的类。下载release版本直接编译安装。
tar -xvzf
cd protobuf-2.5.0
./configure --prefix=/usr/local/protobuf
make && make install
下载地址()
安装PHP Plugin
第二步,安装protoc的 plugin,需要使用composer安装,感兴趣的可以访问
这个插件可以将proto文件转换到PHP文件,在PHP应用中引用后,可以将二进制格式的Protocol Buffers数据转换为PHP的对象
unzip
cd protoc-gen-php-master
curl -sS | php
php install
/usr/local/protobuf/bin/protoc --plugin=bin/protoc-gen-php --php_out=php_kingso -I. o
下载地址()
安装php-protocolbuffers
第三步,安装php-protocolbuffers,这是一个PHP扩展,在第二步中已经完成了proto文件到PHP文件的转换,但是对PHP对象的各种操作还需要这个扩展中的API方法
phpize
./configure
make && make install
然后在你的配置文件中添加
extension = ""
下载地址()
编写代码
第四步,借助上面提到的扩展的各种API方法,可以简单地get出自己需要的字段完成后续工作
require "....../"
$ks_result = KSResult::parseFromString($kingso_res);
$ks_result->get('xxx_name');
The world Cup Football Final英语作文
Unit 7 After school Period 2
OFFICE2007每次打开word时都显示配置microsoft office professio
英语作文Let the Surprise Speak of Your Love
浅谈php中curl和fsockopen的应用
Jolie drops battle over perfume named Shilohy英语作文
Zend studio for eclipse中使php可以调用mysql相关函数的设置方
whats your plan for dragon boat festival英语作文
英语短文Do Old Folks Still Appreciate Humor?
How to Prepare for IELTS高中英语作文
少儿英语小故事:She Practices Flips for the Olympic
用Photoshop如何绘制Google Currents图标
如何将Coreldraw图像文件导入Photoshop
英语美文:Bush, watch out for the pretzels
六下英语Unit5Ourearthlookslikethisfromspace教案
Diaspora Finance Powers Global Development美文欣赏
php中file-get-contents与curl性能比较
如何在PHP中处理Protocol Buffers数据
在小学数学教学中如何处理好教材与教学的关系
英语作文推荐:The Rewards of the Professions
PHP基于CURL进行POST数据上传实例
My favorite place of school 的优秀英语作文及其译文
Protocol Buffers在数据采集与传输系统建设方式论文
Sports should not be encouraged的雅思作文
Introduce two famous sport star英语作文
php中file-get-contents与curl性能比较分析的内容
Twenty Rules for Happy Life句子大全
关于JavaScript中isPrototypeOf函数作用和使用实例
商务英语阅读: The growing cult of ‘try before you buy’
The Impact of Information Explosion高中英语作文
数据分析师发展前景如何
The Spirit of Two Broke Girls英语作文
php中file-get-contents与curl性能分析
PHP如何使用curl发送GET和POST请求
有关「Alt」「Ctrl」「Shift」在PHOTOSHOP中的应用介绍
PHP如何用curl发送GET和POST请求
php中file-get-contents与curl性能比较分析
A Letter to the Editor of a Newspaper英语四级作文
Choice of large enterprises or small英语四级作文
初中英语《Unit 1 Will people have robots》教学设计