PHPackages                             selaz/buffertools - 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. selaz/buffertools

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

selaz/buffertools
=================

Toolbox for working with binary and hex data. Similar to NodeJS Buffer.

06001PHP

Since Sep 13Pushed 2y agoCompare

[ Source](https://github.com/selaz/buffertools-php)[ Packagist](https://packagist.org/packages/selaz/buffertools)[ RSS](/packages/selaz-buffertools/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (1)

Buffertools
===========

[](#buffertools)

This library provides a `Buffer` and `Parser` class to make dealing with binary data in PHP easier. `Templates` extend this by offering a read/write interface for larger serialized structures.

[![Build Status](https://camo.githubusercontent.com/7a17d4219ba86b5b6ac9c1e9cb64fac8ba333598dfb4186914d2a6df44de63c7/68747470733a2f2f7472617669732d63692e6f72672f4269742d576173702f627566666572746f6f6c732d7068702e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Bit-Wasp/buffertools-php)[![Code Coverage](https://camo.githubusercontent.com/f5ba38d7fa3680268d58795d82002fd8993b8274b4371b008d38dc0474590641/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6269742d776173702f627566666572746f6f6c732d7068702f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/bit-wasp/buffertools-php/?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/fbfc8005b87d2a2b7d6f8b1cfb839a06aab5400b82f18d089c980f69f472fef8/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4269742d576173702f627566666572746f6f6c732d7068702f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/Bit-Wasp/buffertools-php/?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/643ee11566a8d56329ad377cc702b7321afff226fc54d21df6994833de144ee7/68747470733a2f2f706f7365722e707567782e6f72672f626974776173702f627566666572746f6f6c732f762f737461626c65)](https://packagist.org/packages/bitwasp/buffertools)[![Total Downloads](https://camo.githubusercontent.com/56b2472df0fcfe0cb43f16e4176301a3334625c05b00fe44e8793a72df1402a5/68747470733a2f2f706f7365722e707567782e6f72672f626974776173702f627566666572746f6f6c732f646f776e6c6f616473)](https://packagist.org/packages/bitwasp/buffertools)[![License](https://camo.githubusercontent.com/ca9d79a08cb3c715be36c48bf3eff2ccb1b21edc7c7827690b6d57ee8cd06c53/68747470733a2f2f706f7365722e707567782e6f72672f626974776173702f627566666572746f6f6c732f6c6963656e7365)](https://packagist.org/packages/bitwasp/buffertools)

Requirements:
-------------

[](#requirements)

- PHP 7.0+
- Composer
- ext-gmp

Installation
------------

[](#installation)

You can install this library via Composer: `composer require bitwasp/buffertools`

Examples
--------

[](#examples)

Buffer's are immutable classes to store binary data. Buffer::hex can be used to initialize from hex Buffer::int can be used to initialize from a positive decimal integer (int|string)

Buffer's main methods are:

- getBinary()
- getHex()
- getInt()

Parser will read Buffers. Parser's main methods are:

- readBytes()
- writeBytes()
- readArray()
- writeArray()

In most cases, the interface offered by Parser should not be used directly. Instead, Templates expose read/write access to larger serialized structures.

- [Example 1: Using buffer to wrap binary data](./examples/usingBuffer.php)
- [Example 2: Using parser to extract binary data](./examples/usingParser.php)
- [Example 3: Using templates to read multiple elements from a parser](./examples/usingTemplates.php)
- [Example 4: Using templates to read/write structured messages](./examples/usingTemplates2.php)

###  Health Score

18

—

LowBetter than 8% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 Bus Factor1

Top contributor holds 84.7% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/60a10991a9de0956065be5839a37480393fb914725e0b0e60172d3f5c263be61?d=identicon)[Selaz](/maintainers/Selaz)

---

Top Contributors

[![afk11](https://avatars.githubusercontent.com/u/5617245?v=4)](https://github.com/afk11 "afk11 (105 commits)")[![rubensayshi](https://avatars.githubusercontent.com/u/649160?v=4)](https://github.com/rubensayshi "rubensayshi (13 commits)")[![BafS](https://avatars.githubusercontent.com/u/588205?v=4)](https://github.com/BafS "BafS (2 commits)")[![sisou](https://avatars.githubusercontent.com/u/1828163?v=4)](https://github.com/sisou "sisou (1 commits)")[![pnx](https://avatars.githubusercontent.com/u/398903?v=4)](https://github.com/pnx "pnx (1 commits)")[![mathroc](https://avatars.githubusercontent.com/u/291531?v=4)](https://github.com/mathroc "mathroc (1 commits)")[![selaz](https://avatars.githubusercontent.com/u/1086350?v=4)](https://github.com/selaz "selaz (1 commits)")

### Embed Badge

![Health badge](/badges/selaz-buffertools/health.svg)

```
[![Health](https://phpackages.com/badges/selaz-buffertools/health.svg)](https://phpackages.com/packages/selaz-buffertools)
```

PHPackages © 2026

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