PHPackages                             byteferry/sdds\_php - 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. byteferry/sdds\_php

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

byteferry/sdds\_php
===================

A PHP library to work with stream decode and encode according to the SDDS Specification.

v0.1.0-alpha(6y ago)031MITPHPPHP ~7.1

Since Sep 14Pushed 6y agoCompare

[ Source](https://github.com/byteferry/sdds_php)[ Packagist](https://packagist.org/packages/byteferry/sdds_php)[ Docs](https://github.com/byteferry/sdds_php)[ RSS](/packages/byteferry-sdds-php/feed)WikiDiscussions master Synced 3d ago

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

```
  /$$$$$$  /$$$$$$$  /$$$$$$$   /$$$$$$
 /$$__  $$| $$__  $$| $$__  $$ /$$__  $$
| $$  \__/| $$  \ $$| $$  \ $$| $$  \__/
|  $$$$$$ | $$  | $$| $$  | $$|  $$$$$$
 \____  $$| $$  | $$| $$  | $$ \____  $$
 /$$  \ $$| $$  | $$| $$  | $$ /$$  \ $$
|  $$$$$$/| $$$$$$$/| $$$$$$$/|  $$$$$$/
 \______/ |_______/ |_______/  \______/

```

SDDS for PHP
============

[](#sdds-for-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8b6c0e16a040e1373a2cf79dccf4d436037153d946f4e14188d9a1b0e647f92f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6279746566657272792f736464735f7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/byteferry/sdds_php)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3dd181cee2b3dd2ff369eb27cef00afc2e5a6c5e1fb443face52340da40fa71b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6279746566657272792f736464735f7068702f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/byteferry/sdds_php)[![Coverage Status](https://camo.githubusercontent.com/4f37cee6b3e6a0476ba77b7a1356bf65b4384e054d0f27cb0961c21c44d3e1f5/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6279746566657272792f736464735f7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/byteferry/sdds_php/code-structure)[![Quality Score](https://camo.githubusercontent.com/d3dd8ddc4d9e15cd2a59eefabe3d58ee39960bf1b90087fa08a65d546306d155/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6279746566657272792f736464735f7068702e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/byteferry/sdds_php)[![Total Downloads](https://camo.githubusercontent.com/014011bf96e802fbc9cca63a33d2a94994ebb497663e404eadc5bd1b114ea1f2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6279746566657272792f736464735f7068702e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/byteferry/sdds_php)

A PHP library to work with stream decode and encode according to the SDDS Specification.

Introduction
------------

[](#introduction)

[中文文档](https://github.com/byteferry/sdds_php/blob/master/README_cn.md)

### What is SDDS?

[](#what-is-sdds)

- Data Structure

SDDS is short word of "stream data dynamic structure".

- DSL

SDDS is a DSL (domain-specific language) .

The schema of SDDS is human-readable and machine and machine-readable.

- Parse Engine

SDDS is a parse engine coded according the SDDS Specification. You can rapid complete the developing of the binary communication program.

### Features

[](#features)

- Multi-protocol support SDDS PHP could enabled the programs to support multiple communication protocols. Each protocol is a channel of the program.
- Data types Support all data types required by the SDDS specification.
- Endianness support

You only need to configure Endianness(Big-Endian, Little-Endian) in the SDDS Schema. If there are individual endianness that are inconsistent, you can also configure them to the corresponding nodes.

- Charset support By default, UTF-8 is used, and you can also specify different encodings.
- Event extension All custom functions can be implemented with the corresponding EventHandler.
- Formula expression Formula expression is supported before encoding or after decoding.
- Easy to debug

The default integration larapack/dd, you can use the browser to debug requests and output to the page via dd.

### Why SDDS?

[](#why-sdds)

Usually we have to write different programs for different communication protocols. However, if you use SDDS, the programs you basically use are the same. And, SDDS has been implemented for you. All you have to do is expand the data stream operations, data types, bit operations, etc. that are not implemented by SDDS. And, through the JSON definition of SDDS Schema. When protocol had been changed, you only need to modify the SDDS Schema without modifying your code. SDDS can greatly speed up your development.

Quick tutorial
--------------

[](#quick-tutorial)

Install
-------

[](#install)

Via Composer

```
$ composer require byteferry/sdds_php:dev-master
```

Usage
-----

[](#usage)

- Step 1: write SDDS Schema according to [SDDS Specification](https://github.com/byteferry/sdds/blob/master/README.md) .
- Step 2: Write the code to call SDDS PHP

1. implement the Channel class:

For example: the channel class is named DecoderChannel.

```
namespace Sdds\Examples\Decode;

use Sdds\Channels\InputChannel;
use Sdds\Channels\ChannelInterface;

class DecodeChannel extends InputChannel implements ChannelInterface
{
    /**
     * @return mixed
     */
    public function registerHandlers(){
        //If there is no Event, then return directly
        return;
    }
}

```

2. Call your DecodeChannel

```
    $channel = DecodeChannel::getInstance();
    $packet_decoder = $channel->getDecoder($your_channel_name,$your_schema_file);
    $data = $packet_decoder->decode($stream_data);

```

3. Debug your SDDS Schema with DD using the http method through the browser. (To facilitate rapid development, we integrated Larapack/dd)
4. Integrate with your communication program.

### Advanced usage

[](#advanced-usage)

Sometimes the existing code doesn't fully meet your needs. At this point, you need to extend the SDDS engine with EventHandler. A typical EventHandler looks like this:

```
namespace Sdds\Examples\Decode;

use Sdds\Constants\ActionTypeContants;
use Sdds\Constants\EventTypeConstants;
use Sdds\Dispatcher\EventHandler;
use Sdds\Dispatcher\EventHandlerInterface;

/**
 * Class StreamHandler
 * @package Sdds\Examples\Decode
 * @desc Note: The class name is best to indicate which type of event you want to listen to.
 */
class StreamHandler extends EventHandler implements EventHandlerInterface
{
    /**
     * Listener constructor.
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * @return mixed
     */
    public function eventType(){
        //Return the type of event you want to listen to
        return EventTypeConstants::EVENT_STREAM;
    }

    /**
     * @return mixed
     */
    public function actionType(){
        //Returns the operation type, which is decoding (INPUT)
        return ActionTypeContants::INPUT;
    }

    /**
     * Because, here is the decoding, that is, the InputStream is being listened to, so all the currently implemented functions must start with read.
     * However, it is not necessary if the implementation is before_action or after_action.
     * @param $stream
     * @param $length
     * @desc The first parameter is always the object you want to listen to, followed by the parameters that the function must have.
     */
    public function readSome($stream, $length){
        //TODO: implement your code here.
    }

}

```

There are 4 kind of EventHandler, See Sdds\\Constants\\EventTypeConstants for details.

We use them to meet different needs:

- DateNode: When we need to add a logical processing of a node.
- Packet: When we want to extend packet processing.
- Stream: When we want to add a custom type, or to add before\_action or after\_action
- Bitwise: When we want to add a bit operation to a node.

After we have these EventHandlers, we need to register these EventHandlers before using.

Then, the DecoderChannel looks like this:

```
namespace Sdds\Examples\Decode;

use Sdds\Channels\InputChannel;
use Sdds\Channels\ChannelInterface;

class DecodeChannel extends InputChannel implements ChannelInterface
{
    /**
     * @return bool
     */
    public function registerHandlers(){
        //Get event dispatcher
        $dispatcher = $this->getDispatcher();
        //Create and register an already implemented EventHandler
        $stream_handler = new $StreamHandler();
        $dispatcher->registerHandler($stream_handler)
    }
}

```

Please see the source code in the examples directory for more details.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please create an issue in the issue tracker.

Credits
-------

[](#credits)

- [ByteFerry](https://github.com/byteferry)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

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

Unknown

Total

1

Last Release

2435d ago

### Community

Maintainers

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

---

Top Contributors

[![BardoQi](https://avatars.githubusercontent.com/u/409367?v=4)](https://github.com/BardoQi "BardoQi (12 commits)")

---

Tags

binary-databinary-streambyte-arraybyte-streambytebuffernetwork-programmingprotocol-parsersddssdds-specificationsocket-programmingstream-bufferstream-processingstreamSocketphp71byte bufferbinary streamSddsbyte arraybyte streamstream buffernetwork binary stream

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/byteferry-sdds-php/health.svg)

```
[![Health](https://phpackages.com/badges/byteferry-sdds-php/health.svg)](https://phpackages.com/packages/byteferry-sdds-php)
```

###  Alternatives

[react/socket

Async, streaming plaintext TCP/IP and secure TLS socket server and client connections for ReactPHP

1.3k116.9M402](/packages/react-socket)[clue/socket-raw

Simple and lightweight OOP wrapper for PHP's low-level sockets extension (ext-sockets).

35111.1M48](/packages/clue-socket-raw)[icicleio/icicle

Icicle is a PHP library for writing asynchronous code using synchronous coding techniques.

1.1k150.9k14](/packages/icicleio-icicle)[hobnob/xml-stream-reader

PHP SAX XML Stream Reader

47192.7k](/packages/hobnob-xml-stream-reader)[symfony/json-streamer

Provides powerful methods to read/write data structures from/into JSON streams.

14440.0k8](/packages/symfony-json-streamer)[trafficcophp/bytebuffer

Node.js inspired byte stream buffer for PHP.

33437.2k17](/packages/trafficcophp-bytebuffer)

PHPackages © 2026

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