msst/byte-buffer
Composer 安装命令:
composer require msst/byte-buffer
包简介
A wrapper for the PHP pack() function. Simple handling of bytes in PHP (original by Ole 'nesQuick' Michaelis)
README 文档
README
This is a improved rewrite of the Project from OleMchls You can also call this a pack() wrapper.
Additional Features
- Autoincrement Offset
- Write Int32, Int64, UInt64 and UTF8 Strings
Install
Installation should be done via composer.
composer require msst/byte-buffer
Or
{
"require": {
"msst/byte-buffer": "dev-master"
}
}
Example
A simple usage example could look like this
<?php require __DIR__ . '/vendor/autoload.php'; use MSST\ByteBuffer\Buffer; $text1 = 'channel_one'; $text2 = "This is a utf8 test message. 😄"; $buffer = new Buffer(4 + 1 + 4 + strlen($text1) + strlen($text2)); $buffer->writeInt32($buffer->length()); $buffer->writeInt8(0x1); $buffer->writeInt32(strlen($text1)); $buffer->write($text1); $buffer->writeUtf8($text2); $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); $result = socket_connect($socket, '127.0.0.1', 3542); socket_write($socket, (string) $buffer, $buffer->length());
Testing
Just working under php > 7.1
./vendor/bin/phpunit
License
Licensed under the MIT license.
Original Project: ByteBuffer by OleMchls
统计信息
- 总下载量: 467
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-03-22