PHPackages                             8ctopus/byte-buffer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. 8ctopus/byte-buffer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

8ctopus/byte-buffer
===================

A php buffer to work with binary data.

1.3.2(5mo ago)25.6k↓50%MITPHPPHP &gt;=8.1CI passing

Since May 12Pushed 5mo ago1 watchersCompare

[ Source](https://github.com/8ctopus/byte-buffer)[ Packagist](https://packagist.org/packages/8ctopus/byte-buffer)[ Docs](https://github.com/8ctopus/byte-buffer)[ RSS](/packages/8ctopus-byte-buffer/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (22)Used By (0)

byte buffer
===========

[](#byte-buffer)

[![packagist](https://camo.githubusercontent.com/840be90fb2e083ccf92d8e474d9599e3d9de573fd45cec4dafcb8439f275ea44/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f627974652d6275666665722f76)](https://packagist.org/packages/8ctopus/byte-buffer)[![downloads](https://camo.githubusercontent.com/deb2ef02c3afb414443c86698617cc3a265676842597b79460dd9a875eff7a64/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f627974652d6275666665722f646f776e6c6f616473)](https://packagist.org/packages/8ctopus/byte-buffer)[![min php version](https://camo.githubusercontent.com/64e4e0091371b1aa3df590182bd9acaf29e6ba6e7b8f0267e2daebe25a20693e/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f627974652d6275666665722f726571756972652f706870)](https://packagist.org/packages/8ctopus/byte-buffer)[![license](https://camo.githubusercontent.com/a52ef8a9888ef801b072510924938634681c9a641a6150e67ecb14cc5d890b4b/68747470733a2f2f706f7365722e707567782e6f72672f3863746f7075732f627974652d6275666665722f6c6963656e7365)](https://packagist.org/packages/8ctopus/byte-buffer)[![tests](https://github.com/8ctopus/byte-buffer/actions/workflows/tests.yml/badge.svg)](https://github.com/8ctopus/byte-buffer/actions/workflows/tests.yml)[![code coverage badge](https://raw.githubusercontent.com/8ctopus/byte-buffer/image-data/coverage.svg)](https://raw.githubusercontent.com/8ctopus/byte-buffer/image-data/coverage.svg)[![lines of code](https://raw.githubusercontent.com/8ctopus/byte-buffer/image-data/lines.svg)](https://raw.githubusercontent.com/8ctopus/byte-buffer/image-data/lines.svg)

A php buffer to work with binary data.

install
-------

[](#install)

```
composer require 8ctopus/byte-buffer

```

demo
----

[](#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
---------

[](#run-tests)

```
composer test

```

clean code
----------

[](#clean-code)

```
composer fix
composer fix-risky

```

reference
=========

[](#reference)

###  Health Score

46

—

FairBetter than 93% of packages

Maintenance70

Regular maintenance activity

Popularity25

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 95.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~64 days

Recently: every ~250 days

Total

21

Last Release

173d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4dafd5f7ef8134a5c9b231686c5da3d6416db09139b45aac0b26952178dffb8a?d=identicon)[8ctopus](/maintainers/8ctopus)

---

Top Contributors

[![8ctopus](https://avatars.githubusercontent.com/u/13252042?v=4)](https://github.com/8ctopus "8ctopus (144 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (7 commits)")

---

Tags

binarybufferbytehexadecimalphpbinaryBufferbyteunpackhexadecimalpack

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/8ctopus-byte-buffer/health.svg)

```
[![Health](https://phpackages.com/badges/8ctopus-byte-buffer/health.svg)](https://phpackages.com/packages/8ctopus-byte-buffer)
```

###  Alternatives

[phpinnacle/buffer

PHPinnacle binary buffer implementation

2493.7k10](/packages/phpinnacle-buffer)[alchemy/binary-driver

A set of tools to build binary drivers

19110.9M39](/packages/alchemy-binary-driver)[nelexa/buffer

Reading And Writing Binary Data (incl. primitive types, ex. byte, ubyte, short, ushort, int, uint, long, float, double). The classes also help with porting the I/O operations of the JAVA code.

33521.7k4](/packages/nelexa-buffer)[danog/phpstruct

PHP implementation of python's struct module.

1110.1k](/packages/danog-phpstruct)[gabrielelana/byte-units

Library to parse, format and convert byte units

1672.2M19](/packages/gabrielelana-byte-units)[trafficcophp/bytebuffer

Node.js inspired byte stream buffer for PHP.

33437.2k17](/packages/trafficcophp-bytebuffer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
