{"id":36981745,"url":"https://github.com/byteferry/sdds_php","last_synced_at":"2026-01-13T22:51:36.889Z","repository":{"id":62498638,"uuid":"181268681","full_name":"byteferry/sdds_php","owner":"byteferry","description":"A PHP library to work with stream decode and encode according to the SDDS Specification.","archived":false,"fork":false,"pushed_at":"2019-09-14T12:01:19.000Z","size":1908,"stargazers_count":0,"open_issues_count":0,"forks_count":1,"subscribers_count":0,"default_branch":"master","last_synced_at":"2023-03-01T18:38:42.343Z","etag":null,"topics":["binary-data","binary-stream","byte-array","byte-stream","bytebuffer","network-programming","protocol-parser","sdds","sdds-specification","socket-programming","stream-buffer","stream-processing"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/byteferry.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-14T06:23:24.000Z","updated_at":"2021-11-17T02:31:00.000Z","dependencies_parsed_at":"2022-11-02T11:47:03.913Z","dependency_job_id":null,"html_url":"https://github.com/byteferry/sdds_php","commit_stats":null,"previous_names":[],"tags_count":null,"template":null,"template_full_name":null,"purl":"pkg:github/byteferry/sdds_php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteferry%2Fsdds_php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteferry%2Fsdds_php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteferry%2Fsdds_php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteferry%2Fsdds_php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/byteferry","download_url":"https://codeload.github.com/byteferry/sdds_php/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/byteferry%2Fsdds_php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28402188,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T14:36:09.778Z","status":"ssl_error","status_checked_at":"2026-01-13T14:35:19.697Z","response_time":56,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["binary-data","binary-stream","byte-array","byte-stream","bytebuffer","network-programming","protocol-parser","sdds","sdds-specification","socket-programming","stream-buffer","stream-processing"],"created_at":"2026-01-13T22:51:36.116Z","updated_at":"2026-01-13T22:51:36.876Z","avatar_url":"https://github.com/byteferry.png","language":"PHP","readme":"```\n  /$$$$$$  /$$$$$$$  /$$$$$$$   /$$$$$$ \n /$$__  $$| $$__  $$| $$__  $$ /$$__  $$\n| $$  \\__/| $$  \\ $$| $$  \\ $$| $$  \\__/\n|  $$$$$$ | $$  | $$| $$  | $$|  $$$$$$ \n \\____  $$| $$  | $$| $$  | $$ \\____  $$\n /$$  \\ $$| $$  | $$| $$  | $$ /$$  \\ $$\n|  $$$$$$/| $$$$$$$/| $$$$$$$/|  $$$$$$/\n \\______/ |_______/ |_______/  \\______/ \n \n```\n# SDDS for PHP\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-travis]][link-travis]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nA PHP library to work with stream decode and encode according to the SDDS Specification.\n  \n## Introduction\n\n[中文文档](https://github.com/byteferry/sdds_php/blob/master/README_cn.md)\n\n### What is SDDS?\n    \n* Data Structure\n \nSDDS is  short word of \"stream data dynamic structure\".\n  \n* DSL\n  \nSDDS is a DSL (domain-specific language) .\n  \nThe schema of SDDS is human-readable  and machine and machine-readable. \n  \n* Parse Engine\n   \nSDDS is a parse engine coded according the SDDS Specification. You can rapid complete the developing of the binary communication program.  \n  \n \n### Features\n  \n- Multi-protocol support\n \nSDDS PHP could enabled the programs to support multiple communication protocols. Each protocol is a channel of the program.\n \n- Data types\n    \nSupport all data types required by the SDDS specification.\n\n- Endianness support\n\nYou 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.\n    \n- Charset support\n   \nBy default, UTF-8 is used, and you can also specify different encodings.\n    \n- Event extension\n    \nAll custom functions can be implemented with the corresponding EventHandler.\n    \n- Formula expression\n \n Formula expression is supported before encoding  or after decoding.\n\n- Easy to debug\n\nThe default integration larapack/dd, you can use the browser to debug requests and output to the page via dd.  \n\n### Why SDDS?\n   \nUsually 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.\n    \nAll 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.\n    \nSDDS can greatly speed up your development.\n  \n## Quick tutorial\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require byteferry/sdds_php:dev-master\n```\n\n## Usage\n\n- Step 1: write SDDS Schema according to [SDDS Specification](https://github.com/byteferry/sdds/blob/master/README.md) .\n  \n- Step 2: Write the code to call SDDS PHP\n  \n1. implement the Channel class:\n    \nFor example: the channel class is named DecoderChannel.\n    \n```\nnamespace Sdds\\Examples\\Decode;\n\nuse Sdds\\Channels\\InputChannel;\nuse Sdds\\Channels\\ChannelInterface;\n\nclass DecodeChannel extends InputChannel implements ChannelInterface\n{\n    /**\n     * @return mixed\n     */\n    public function registerHandlers(){\n        //If there is no Event, then return directly\n        return;\n    }\n}\n```    \n  \n2. Call your DecodeChannel\n \n```\n    $channel = DecodeChannel::getInstance();\n    $packet_decoder = $channel-\u003egetDecoder($your_channel_name,$your_schema_file);\n    $data = $packet_decoder-\u003edecode($stream_data);\n    \n```  \n    \n3. Debug your SDDS Schema with DD using the http method through the browser. (To facilitate rapid development, we integrated Larapack/dd)\n  \n4. Integrate with your communication program.\n  \n### Advanced usage\n     \nSometimes the existing code doesn't fully meet your needs. At this point, you need to extend the SDDS engine with EventHandler.\n     \nA typical EventHandler looks like this:\n   \n```\nnamespace Sdds\\Examples\\Decode;\n\nuse Sdds\\Constants\\ActionTypeContants;\nuse Sdds\\Constants\\EventTypeConstants;\nuse Sdds\\Dispatcher\\EventHandler;\nuse Sdds\\Dispatcher\\EventHandlerInterface;\n\n/**\n * Class StreamHandler\n * @package Sdds\\Examples\\Decode\n * @desc Note: The class name is best to indicate which type of event you want to listen to.\n */\nclass StreamHandler extends EventHandler implements EventHandlerInterface\n{\n    /**\n     * Listener constructor.\n     */\n    public function __construct()\n    {\n        parent::__construct();\n    }\n\n    /**\n     * @return mixed\n     */\n    public function eventType(){\n        //Return the type of event you want to listen to\n        return EventTypeConstants::EVENT_STREAM;\n    }\n\n    /**\n     * @return mixed\n     */\n    public function actionType(){\n        //Returns the operation type, which is decoding (INPUT)\n        return ActionTypeContants::INPUT;\n    }\n\n    /**\n     * Because, here is the decoding, that is, the InputStream is being listened to, so all the currently implemented functions must start with read.\n     * However, it is not necessary if the implementation is before_action or after_action.\n     * @param $stream\n     * @param $length\n     * @desc The first parameter is always the object you want to listen to, followed by the parameters that the function must have.\n     */\n    public function readSome($stream, $length){\n        //TODO: implement your code here.\n    }\n     \n\n}\n``` \n   \nThere are 4 kind of EventHandler, See Sdds\\Constants\\EventTypeConstants for details.\n    \nWe use them to meet different needs:\n    \n- DateNode: When we need to add a logical processing of a node.\n  \n- Packet: When we want to extend packet processing.\n  \n- Stream: When we want to add a custom type, or to add before_action or after_action\n  \n- Bitwise: When we want to add a bit operation to a node.\n\nAfter we have these EventHandlers, we need to register these EventHandlers before using.\n    \nThen, the DecoderChannel looks like this:\n    \n```\nnamespace Sdds\\Examples\\Decode;\n\nuse Sdds\\Channels\\InputChannel;\nuse Sdds\\Channels\\ChannelInterface;\n\nclass DecodeChannel extends InputChannel implements ChannelInterface\n{\n    /**\n     * @return bool\n     */\n    public function registerHandlers(){\n        //Get event dispatcher\n        $dispatcher = $this-\u003egetDispatcher();\n        //Create and register an already implemented EventHandler\n        $stream_handler = new $StreamHandler();\n        $dispatcher-\u003eregisterHandler($stream_handler)\n    }\n}\n```       \n\nPlease see the source code in the examples directory for more details.\n\n## Contributing\n  \nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for details.\n  \n## Security\n  \nIf you discover any security related issues, please create an issue in the issue tracker.\n  \n## Credits\n   \n- [ByteFerry][link-author]\n- [All Contributors][link-contributors]\n   \n## License\n    \nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n      \n[ico-version]: https://img.shields.io/packagist/v/byteferry/sdds_php.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-travis]: https://img.shields.io/travis/byteferry/sdds_php/master.svg?style=flat-square\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/byteferry/sdds_php.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/byteferry/sdds_php.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/byteferry/sdds_php.svg?style=flat-square\n    \n[link-packagist]: https://packagist.org/packages/byteferry/sdds_php\n[link-travis]: https://travis-ci.org/byteferry/sdds_php\n[link-scrutinizer]: https://scrutinizer-ci.com/g/byteferry/sdds_php/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/byteferry/sdds_php\n[link-downloads]: https://packagist.org/packages/byteferry/sdds_php\n[link-author]: https://github.com/byteferry\n[link-contributors]: ../../contributors\n[link-pecl-php-operator]:https://github.com/php/pecl-php-operator\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyteferry%2Fsdds_php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbyteferry%2Fsdds_php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbyteferry%2Fsdds_php/lists"}