PHPackages                             uniondrug/packet - 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. uniondrug/packet

ActiveLibrary

uniondrug/packet
================

Uniondrug Packet Component for uniondrug/framework

2.0.3(8y ago)01.5k1PHPPHP &gt;=5.6

Since Mar 28Pushed 8y ago3 watchersCompare

[ Source](https://github.com/uniondrug/packet)[ Packagist](https://packagist.org/packages/uniondrug/packet)[ RSS](/packages/uniondrug-packet/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (4)Dependencies (1)Versions (6)Used By (1)

packet
======

[](#packet)

> THANKS：本模块来自 [FastD](https://github.com/fastdlabs/packet)

PHP 数据打包、解包工具，支持二进制，json格式.

### ＃composer

[](#composer)

```
{
    "require": {
        "uniondrug/packet": "~1.1"
    }
}
```

### ＃使用

[](#使用)

二进制数据打包的时候程序会将内容加入 “盐(SALT)” 来强化数据安全性，如果需要自定义盐值，需要在实现类中重写 `Uniondrug\Packet\PacketInterface::SALT` 类常量。

##### ＃二进制

[](#二进制)

```
use Uniondrug\Packet\Binary;

$origin = ['name' => 'janhuang'];

$data = Binary::encode($origin);
$origin = Binary::decode($data);

/**
 * Array(
 *      "name" => "janhuang"
 * )
 */
```

##### ＃JSON

[](#json)

JSON 数据在打包的时候同样会加入盐值，程序自行追加，并且会对盐值进行在加密，在数据处理解析返回会自动移除盐值，返回纯净数据。因此在传入数据的时候需要注意不要存在 `packet_salt` 字段。

```
use Uniondrug\Packet\Json;

$origin = ['name' => 'janhuang'];

$data = Json::encode($origin);
$origin = Json::decode($data);

/**
 * Array(
 *      "name" => "janhuang"
 * )
 */
```

### ＃Testing

[](#testing)

```
phpunit

```

License MIT
===========

[](#license-mit)

###  Health Score

30

—

LowBetter than 65% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 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 ~10 days

Total

5

Last Release

2924d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/865ceb7d8226574735eab8fc82de9cfbc4a708c291b3c816e75d53944348b686?d=identicon)[wsfuyibing](/maintainers/wsfuyibing)

---

Top Contributors

[![xueron](https://avatars.githubusercontent.com/u/2560873?v=4)](https://github.com/xueron "xueron (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/uniondrug-packet/health.svg)

```
[![Health](https://phpackages.com/badges/uniondrug-packet/health.svg)](https://phpackages.com/packages/uniondrug-packet)
```

PHPackages © 2026

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