PHPackages                             tourze/workerman-block-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/workerman-block-protocol

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

tourze/workerman-block-protocol
===============================

Workerman积木协议

0.0.1(5mo ago)00MITPHPCI passing

Since Nov 14Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/workerman-block-protocol)[ Packagist](https://packagist.org/packages/tourze/workerman-block-protocol)[ RSS](/packages/tourze-workerman-block-protocol/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (2)Used By (0)

Workerman Block Protocol
========================

[](#workerman-block-protocol)

[English](README.md) | [中文](README.zh-CN.md)

[![Latest Version](https://camo.githubusercontent.com/16644d200116391d06ead34a70dc60c0c92e20eb80fd4913a03367d2cdf9df94/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f776f726b65726d616e2d626c6f636b2d70726f746f636f6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/workerman-block-protocol)[![Build Status](https://camo.githubusercontent.com/3c75cbf80739d3f42836bab035102123295320544fd5b4157e0fec7fc34b2780/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f7068702d6d6f6e6f7265706f2f63692e796d6c3f6272616e63683d6d6173746572267374796c653d666c61742d737175617265)](https://github.com/tourze/php-monorepo/actions)[![Quality Score](https://camo.githubusercontent.com/43930c8561a14d3f5a68c62b692ee20749bac4c043e09e88fd3fdd611660198f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f746f75727a652f7068702d6d6f6e6f7265706f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/php-monorepo)[![Code Coverage](https://camo.githubusercontent.com/fce86ff4532b4694c22512e5e192a270f73dd27d6e5495fffb59c73cf14de807/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f746f75727a652f7068702d6d6f6e6f7265706f2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/tourze/php-monorepo)[![Total Downloads](https://camo.githubusercontent.com/415a726f15229a12e0ec4022a1d19092fb5d8838f4f7e9ed4acbb02d18c23c9b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f776f726b65726d616e2d626c6f636b2d70726f746f636f6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/workerman-block-protocol)[![License](https://camo.githubusercontent.com/9cabe2ba98d8dae13890170e2af1a57b405edde1abbf24541c034b40cb256e8c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f746f75727a652f7068702d6d6f6e6f7265706f2e7376673f7374796c653d666c61742d737175617265)](https://github.com/tourze/php-monorepo/blob/master/LICENSE)

A modular protocol processing library for Workerman framework, using a "building blocks" approach to handle complex protocol data parsing and encoding.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Requirements](#requirements)
- [Installation](#installation)
- [Quick Start](#quick-start)
    - [Basic Usage](#basic-usage)
- [Available Handlers](#available-handlers)
    - [Ascii Handler](#ascii-handler)
    - [UnpackData Handler](#unpackdata-handler)
    - [Length Handler](#length-handler)
    - [JSON Handler](#json-handler)
    - [Base64 Handler](#base64-handler)
    - [Compression Handler](#compression-handler)
    - [Response Handler](#response-handler)
- [Advanced Usage](#advanced-usage)
    - [Creating Custom Handlers](#creating-custom-handlers)
    - [Complex Protocol Example](#complex-protocol-example)
- [Testing](#testing)
- [Contributing](#contributing)
- [Changelog](#changelog)
    - [v1.0.0](#v100)
- [License](#license)

Features
--------

[](#features)

- 🔧 **Modular Design**: Combine multiple handlers to process complex protocols
- 🚀 **High Performance**: Fully compatible with Workerman's protocol interface
- 📦 **Extensible**: Easy to create custom handlers for specific needs
- 🔄 **Bidirectional**: Support both encoding and decoding operations
- 🛡️ **Type Safe**: Built with PHP 8.1+ features and strict typing
- 📊 **Comprehensive**: Handles common data processing scenarios:
    - ASCII character validation
    - Fixed-length data parsing
    - JSON data processing
    - Base64 encoding/decoding
    - Data compression/decompression
    - Length-prefixed messages
    - Custom response generation

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Workerman 5.1 or higher
- ext-zlib extension

Installation
------------

[](#installation)

```
composer require tourze/workerman-block-protocol
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
