当前位置:网站首页>Tp6 use protobuf
Tp6 use protobuf
2022-07-29 07:14:00 【Kiki Moyu】
The following is not required c Expanded version
Download from the official website protoc Script
window Download win32 perhaps win64 edition ,mac download osx edition
Unzip and get the folder ( With mac For example )protoc-21.4-osx-x86_64, Runnable script protoc stay bin Under the folder
To write proto Message type , Save as person.proto
syntax="proto3";
package proto;
message Person{
string name=1;
int32 age=2;
}Execute the script , Generate class library
protoc --php_out=protobuf/compile --proto_path=protobuf/proto protobuf/proto/*.proto
# The first path is The location of the generated file and the language it is compiled into , The second is storage proto The location of the file , The third represents all under the current file proto file
# proto Files need to be in the same directory , Cannot be under subfolders Generate files after execution
GPBMetadata/Person.php
Proto/Person.php
stay php Use in
Install dependent extensions under the current project , install composer Dependency expansion
composer require google/protobufNote that the domestic image may fail to download , You can change the image to https://repo.packagist.org And then execute it again
serialize
......
use GPBMetadata/Person;
use Proto/Person;
......
$person = new Person();
$person->setName(" Zhang San ");
$person->setAge(27);
$data = $person->serializeToString();
......Deserialization
......
use GPBMetadata/Person;
use Proto/Person;
......
$data = $this->request->param('protodata');
$person = new Person();
$person->mergeFromString($data);
$person->getName();
$person->getAge();
......边栏推荐
- ETL为什么经常变成ELT甚至LET?
- Vmware16 create virtual machine: cannot create a new virtual machine, do not have permission to perform this operation
- Summary of 2022 SQL classic interview questions (with analysis)
- Hj37 statistics of the total number of rabbits per month Fibonacci series
- tp6 使用 ProtoBuf
- Student achievement ranking system based on C language design
- NPM install reports an error NPM err could not resolve dependency NPM err peer
- 2D cartoon rendering - advanced skills
- CAN&CANFD综合测试分析软件LKMaster与PCAN-Explorer 6分析软件的优势对比
- gin 模版
猜你喜欢

Is online legend software testing training really so black hearted? Are they all scams?

Student achievement ranking system based on C language design

数组的子集能否累加出K

Operator3-设计一个operator

JS 鸡生蛋与蛋生鸡问题,Object与Function究竟谁出现的更早?Function算不算Function的实例?

记 - 踩坑-实时数仓开发 - doris/pg/flink

OCR光学字符识别方法汇总

SSH password free login - two virtual machines establish password free channel two-way trust

WPF简单登录页面的完成案例

Personal blog system (with source code)
随机推荐
图像加噪声与矩阵求逆
[cf1054h] epic Revolution -- number theory, convolution, arbitrary modulus NTT
1172. The plate stack has a sequence table + stack
Redis基础篇
Unity exploration plot access design analysis & process + code specific implementation
最新百亿量化私募名单
[CF1054H] Epic Convolution——数论,卷积,任意模数NTT
Hj37 statistics of the total number of rabbits per month Fibonacci series
Implementation of DDP cluster distributed training under pytoch multi GPU conditions (brief introduction - from scratch)
【C语言刷LeetCode】1054. 距离相等的条形码(M)
城市花样精~侬好!DESIGN#可视化电台即将开播
npm install 时,卡住不动,五种解决方法
spark学习笔记(七)——sparkcore核心编程-RDD序列化/依赖关系/持久化/分区器/累加器/广播变量
buck电路boot和ph引脚实测
MVFuseNet:Improving End-to-End Object Detection and Motion Forecasting through Multi-View Fusion of
Simulation volume leetcode [normal] 061. rotating linked list
怎么会不喜欢呢,CICD中轻松发送邮件
Flink real-time warehouse DWD layer (Kafka associated with MySQL lookup join) template code
Some tips of vim text editor
Student achievement ranking system based on C language design