PHPackages                             workbunny/mysql-protocol - 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. [Database &amp; ORM](/categories/database)
4. /
5. workbunny/mysql-protocol

ActiveLibrary[Database &amp; ORM](/categories/database)

workbunny/mysql-protocol
========================

The MySQL protocol implemented by PHP

0.0.2(1y ago)1561Apache-2.0PHPPHP &gt;=8.1

Since May 7Pushed 1y agoCompare

[ Source](https://github.com/workbunny/mysql-protocol)[ Packagist](https://packagist.org/packages/workbunny/mysql-protocol)[ RSS](/packages/workbunny-mysql-protocol/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

[![workbunny](https://camo.githubusercontent.com/e2b1164338390ab45783434659e3e419e0c3b50fbe140c697ba1f82f59015ad6/68747470733a2f2f6368617a366368657a2e636e2f696d616765732f776f726b62756e6e792d6c6f676f2e706e67)](https://camo.githubusercontent.com/e2b1164338390ab45783434659e3e419e0c3b50fbe140c697ba1f82f59015ad6/68747470733a2f2f6368617a366368657a2e636e2f696d616765732f776f726b62756e6e792d6c6f676f2e706e67)

**workbunny/mysql-protocol**

**🐇 A PHP implementation of MySQL Protocol. 🐇**

A PHP implementation of MySQL Protocol
======================================

[](#a-php-implementation-of-mysql-protocol)

安装
--

[](#安装)

### 依赖

[](#依赖)

- PHP &gt;= 8.1
- [workerman](https://github.com/walkor/workerman) &gt;= 4.0 【可选，`workerman`环境】

### 安装

[](#安装-1)

```
composer require workbunny/mysql-protocol

```

使用
--

[](#使用)

### Binary 二进制流

[](#binary-二进制流)

- `Binary`提供了二进制流和字节组之间的互转能力（注：PHP是二进制安全语言）
- `Binary`提供了基础的字节组读写操作能力，读写操作的指针相互隔离，读写指针默认从0位开始
- `payload`支持传递`字符串`、`字节数组`、`iterable类型的字节组`、`null`

```
use Workbunny\MysqlProtocol\Utils\Binary;

$binary = new Binary("workbunny");
# 输出字节组
$binary->unpack();
# 输出字符串(输入明文则返回明文，输入二进制数据则返回二进制)
$binary->pack();
# 输出原始负载
$binary->payload();
```

#### 读

[](#读)

- 默认以0位开始，每次操作都会递增相应字节位置

```
use Workbunny\MysqlProtocol\Utils\Binary;

$binary = new Binary("workbunny");

# 设置读取指针
$binary->setReadCursor();
# 获取读取指针
$binary->getReadCursor();

# 读取一个字节
$binary->readByte();
# 读取多个字节
$binary->readBytes();
# 读取一个整数(长度编码)
$binary->readLenEncInt();
# 读取一个字符串(长度编码)
$binary->readLenEncString();
# 读取一个无符号整数(长度编码)
$binary->readUB();
# 读取一个字符串(以NULL结束)
$binary->readNullTerminated();
```

#### 写

[](#写)

- 默认以0位开始，每次操作都会递增相应字节位置

```
use Workbunny\MysqlProtocol\Utils\Binary;

$binary = new Binary();

# 设置写指针
$binary->setWriteCursor();
# 获取写取指针
$binary->getWriteCursor();

# 写一个字节
$binary->writeByte();
# 写多个字节
$binary->writeBytes();
# 写一个整数(长度编码)
$binary->writeLenEncInt();
# 写一个字符串(长度编码)
$binary->writeLenEncString();
# 写一个无符号整数(长度编码)
$binary->writeUB();
# 写一个字符串(以NULL结束)
$binary->writeNullTerminated();
```

### Packet 协议包

[](#packet-协议包)

- `Packet`提供了`MySQL`协议基础的二进制包数据的解析与封装能力
- `Packet`提供`PacketInterface`自定义实现
- 默认13种`Packet`覆盖了常见`MySQL`交互动作

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance46

Moderate activity, may be stable

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity37

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

2

Last Release

417d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/22535862?v=4)[chaz6chez](/maintainers/Chaz6Chez)[@chaz6chez](https://github.com/chaz6chez)

---

Top Contributors

[![chaz6chez](https://avatars.githubusercontent.com/u/22535862?v=4)](https://github.com/chaz6chez "chaz6chez (21 commits)")

---

Tags

mysql-packetmysql-protocolmysql-serverphp

### Embed Badge

![Health badge](/badges/workbunny-mysql-protocol/health.svg)

```
[![Health](https://phpackages.com/badges/workbunny-mysql-protocol/health.svg)](https://phpackages.com/packages/workbunny-mysql-protocol)
```

###  Alternatives

[jdorn/sql-formatter

a PHP SQL highlighting library

3.9k117.2M118](/packages/jdorn-sql-formatter)[propel/propel1

Propel is an open-source Object-Relational Mapping (ORM) for PHP5.

8351.6M87](/packages/propel-propel1)[jfelder/oracledb

Oracle DB driver for Laravel

11518.4k](/packages/jfelder-oracledb)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
