2017 © Pedro Peláez
 

library ByteBuffer

Node.js inspired byte stream buffer for PHP.

image

TrafficCophp/ByteBuffer

Node.js inspired byte stream buffer for PHP.

  • Monday, February 20, 2017
  • by nesQuick
  • Repository
  • 2 Watchers
  • 23 Stars
  • 23,779 Installations
  • PHP
  • 11 Dependents
  • 0 Suggesters
  • 9 Forks
  • 1 Open issues
  • 3 Versions
  • 15 % Grown

The README.md

PHP Library for reading and writing binary data

Build Status No Maintenance Intended, (*1)

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., (*2)

Install

Installation should be done via composer., (*3)

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

Example

A simple usage example could look like this, (*4)

<?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., (*5)

The Versions

20/02 2017

dev-master

9999999-dev

Node.js inspired byte stream buffer for PHP.

  Sources   Download

MIT

library wrapper stream socket buffer pack bytehandling binary data

13/01 2016

v0.3

0.3.0.0

Node.js inspired byte stream buffer for PHP.

  Sources   Download

MIT

library wrapper stream socket buffer pack bytehandling binary data

27/03 2012

v0.2

0.2.0.0

Node.js inspired byte stream buffer for PHP.

  Sources   Download

MIT

library wrapper stream socket buffer pack bytehandling binary data