定制 trafficcophp/bytebuffer 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

trafficcophp/bytebuffer

最新稳定版本:v0.3

Composer 安装命令:

composer require trafficcophp/bytebuffer

包简介

Node.js inspired byte stream buffer for PHP.

README 文档

README

Build Status No Maintenance Intended

I intentionally needed that for writing a PHP Client for TrafficCop. But the source grows so I decided to move it into an own package. You can also call this a pack() wrapper.

Install

Installation should be done via composer.

{
    "require": {
        "TrafficCophp/ByteBuffer": "dev-master"
    }
}

Example

A simple usage example could look like this

<?php

require __DIR__ . '/vendor/.composer/autoload.php';

use TrafficCophp\ByteBuffer\ByteBuffer;

$channel = 'channel_one';
$message = 'php';

$buffer = new ByteBuffer(4 + 1 + 4 + strlen($channel) + strlen($message));
$buffer->writeInt32BE($buffer->length(), 0);
$buffer->writeInt8(0x1, 4);
$buffer->writeInt32BE(strlen($channel), 5);
$buffer->write($channel, 9);
$buffer->write($message, 9 + strlen($channel));

$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());

ToDo's

  • Write Documentation
  • Improve examples
  • Allow Buffer as constructor
  • Write test for concatinating buffers

License

Licensed under the MIT license.

统计信息

  • 总下载量: 403.44k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 33
  • 点击次数: 2
  • 依赖项目数: 16
  • 推荐数: 0

GitHub 信息

  • Stars: 33
  • Watchers: 2
  • Forks: 12
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-03-18