2017 © Pedro Peláez
 

library bytebuffer

Node.js inspired byte stream buffer for PHP.

image

t3ran13/bytebuffer

Node.js inspired byte stream buffer for PHP.

  • Sunday, February 18, 2018
  • by t3ran13
  • Repository
  • 1 Watchers
  • 0 Stars
  • 178 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 9 Forks
  • 0 Open issues
  • 3 Versions
  • 19 % 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 Via Composer

composer require t3ran13/bytebuffer

Example

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

<?php

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

use t3ran13\ByteBuffer\ByteBuffer;

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

$buffer = new ByteBuffer();
$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., (*4)

The Versions

18/02 2018

dev-master

9999999-dev

Node.js inspired byte stream buffer for PHP.

  Sources   Download

MIT

by Avatar t3ran13

library wrapper stream socket buffer pack bytehandling binary data

18/02 2018

v1.0.1

1.0.1.0

Node.js inspired byte stream buffer for PHP.

  Sources   Download

MIT

by Avatar t3ran13

library wrapper stream socket buffer pack bytehandling binary data

06/12 2017

v1.0.0

1.0.0.0

Node.js inspired byte stream buffer for PHP.

  Sources   Download

MIT

by Avatar t3ran13

library wrapper stream socket buffer pack bytehandling binary data