8ctopus/byte-buffer
Composer 安装命令:
composer require 8ctopus/byte-buffer
包简介
A php buffer to work with binary data.
README 文档
README
A php buffer to work with binary data.
install
composer require 8ctopus/byte-buffer
demo
use Oct8pus\ByteBuffer\ByteBuffer; use Oct8pus\ByteBuffer\Endian; use Oct8pus\ByteBuffer\Origin; require_once __DIR__ . '/vendor/autoload.php'; echo "Let's create a new little endian buffer and write string Hello World\n"; $buffer = (new ByteBuffer()) ->setEndian(Endian::LittleEndian) ->writeString('Hello World'); echo $buffer . "\n"; // hex (12/12): 48656c6c 6f20576f 726c6400 - Hello World. echo "Add byte 0x07, word 0xFFFF and dword 0xAABBCCDD\n"; $buffer ->writeByte(0x07) ->writeWord(0xFFFF) ->writeDword(0xAABBCCDD); echo $buffer; // hex (19/19): 48656c6c 6f20576f 726c6400 07ffffdd ccbbaa - Hello World........ echo "\nSeek buffer back to origin\n"; $buffer->seek(0, Origin::Start); echo $buffer; // hex (0/19): 48656c6c 6f20576f 726c6400 07ffffdd ccbbaa - Hello World........ echo "\nRead string from buffer\n"; echo $buffer->readString() . "\n"; // Hello World echo "\nRead byte, word and dword\n"; printf("0x%02X\n", $buffer->readByte()); printf("0x%04X\n", $buffer->readword()); printf("0x%08X\n", $buffer->readDword()); // 0x07 // 0xFFFF // 0xAABBCCDD echo "\nDelete World from buffer\n"; $buffer->delete(6, 5); echo $buffer; // hex (19/14): 48656c6c 6f200007 ffffddcc bbaa - Hello ........ echo "\nCalculate buffer crc32b\n"; echo '0x'. strtoupper($buffer->crc32b(true)) . "\n"; // 0xF3B2604E echo "\nInsert Parrot at position 6\n"; $buffer ->seek(6, Origin::Start) ->insertChars('Parrot'); echo $buffer; // hex (12/20): 48656c6c 6f205061 72726f74 0007ffff ddccbbaa - Hello Parrot........ echo "\nCopy Parrot to a new buffer\n"; $parrot = $buffer->copy(6, 6); echo $parrot; // hex (0/6): 50617272 6f74 - Parrot echo "\nInvert Parrot\n"; echo $parrot->invert(); // hex (0/6): 746f7272 6150 - torraP echo "\nCalculate hashes\n"; echo 'md5: ' . $parrot->md5(false) . "\n"; echo 'sha1: ' . $parrot->sha1(false) . "\n"; echo 'sha256: ' . $parrot->sha256(false) . "\n"; // md5: 4264ed2a05f9548fb3b26601c1c904c4 // sha1: d50da4682cdb41c803075168f5c132fd33ffa34d // sha256: e2d6ddb19ca9c3396521297f4a09581c1187acb29931c8d4431941be71d2215c echo "\nTruncate buffer\n"; echo $parrot->truncate(); // hex (0/0):
run tests
composer test
clean code
composer fix
composer fix-risky
reference
8ctopus/byte-buffer 适用场景与选型建议
8ctopus/byte-buffer 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 6.12k 次下载、GitHub Stars 达 2, 最近一次更新时间为 2022 年 05 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「Buffer」 「pack」 「binary」 「hexadecimal」 「byte」 「unpack」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 8ctopus/byte-buffer 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 8ctopus/byte-buffer 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 8ctopus/byte-buffer 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP implementation of python's struct module.
Library implementing buffer utilities
Library to communicate with CRMBuffer
This library allows you to use the Buffer API using PHP
Codeigniter 3 complete solution pack with enhanced & modern framework extensions
A PHP Framework that allows you to encode and decode arbitrary ASN.1 structures using the ITU-T X.690 Encoding Rules.
统计信息
- 总下载量: 6.12k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 19
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-05-12