PHPackages                             sqrt-cat/proto-bin - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. sqrt-cat/proto-bin

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

sqrt-cat/proto-bin
==================

A PHP library similar to protobuf for binary protocol packaging/unpacking, which can package biz data into binary format for efficient transmission. Implemented using native PHP with no other external dependencies. Supports data types such as fixed length and variable length.

v1.0.0(12mo ago)01MITPHPPHP &gt;=5.6

Since May 12Pushed 12mo ago1 watchersCompare

[ Source](https://github.com/sqrt-cat/proto-bin)[ Packagist](https://packagist.org/packages/sqrt-cat/proto-bin)[ RSS](/packages/sqrt-cat-proto-bin/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

ProtoBin
========

[](#protobin)

ProtoBin 是一个使用PHP原生开发的二进制协议的序列化库。在 PHP 前提下，理念与 Protobuf 类似，但更加简单易用。

支持数据类型
------

[](#支持数据类型)

### 定长类

[](#定长类)

const TYPE\_TINYINT = 'tinyint'; const TYPE\_INT16 = 'int16'; const TYPE\_INT32 = 'int32'; const TYPE\_INT64 = 'int64';

### 变长类

[](#变长类)

const TYPE\_STRING = 'string'; const TYPE\_TEXT = 'text';

你可能会吐槽为何没有非标量数据类型，其实可以序列化后用text类型来存储。

### 示例代码

[](#示例代码)

```
# 安装依赖
composer require sqrt-cat/proto-bin

```

#### 消息体定义

[](#消息体定义)

```
