PHPackages                             hardcastle/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. hardcastle/buffer

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

hardcastle/buffer
=================

PHP implementation of the NodeJS Buffer class

1.0.1(1mo ago)29.9k↓56.1%2MITPHPPHP ^8.2CI passing

Since Dec 8Pushed 1mo ago2 watchersCompare

[ Source](https://github.com/AlexanderBuzz/Buffer)[ Packagist](https://packagist.org/packages/hardcastle/buffer)[ RSS](/packages/hardcastle-buffer/feed)WikiDiscussions main Synced yesterday

READMEChangelog (5)Dependencies (9)Versions (6)Used By (2)

Buffer
======

[](#buffer)

PHP implementation of the Node.js Buffer module, available for PHP 8.2+.

Features
--------

[](#features)

- Fully compliant with Node.js Buffer API.
- Supports various encodings: `utf8`, `hex`, `base64`.
- Memory-efficient storage using `SplFixedArray`.
- Supports reading and writing various data types:
    - Integers: `Int8`, `UInt8`, `Int16BE/LE`, `UInt16BE/LE`, `Int32BE/LE`, `UInt32BE/LE`.
    - Floats &amp; Doubles: `FloatBE/LE`, `DoubleBE/LE`.
- Utility methods: `fill`, `write`, `copy`, `compare`, `indexOf`, `lastIndexOf`, `includes`, `swap16/32/64`.
- `ArrayAccess` implementation for easy byte access.

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

[](#installation)

```
composer require hardcastle/buffer
```

Usage
-----

[](#usage)

### Create Buffer

[](#create-buffer)

```
use Hardcastle\Buffer\Buffer;

// From size
$buf = Buffer::alloc(10);

// From array
$buf = Buffer::from([0x62, 0x75, 0x66, 0x66, 0x65, 0x72]);

// From string
$buf = Buffer::from('hello world', 'utf8');

// From hex
$buf = Buffer::from('627566666572', 'hex');

// From base64
$buf = Buffer::from('aGVsbG8=', 'base64');
```

### Access &amp; Modification

[](#access--modification)

```
$buf = Buffer::alloc(10);
$buf[0] = 0x41; // 'A'
echo $buf[0]; // 65
echo $buf->length; // 10

$buf->write('hello', 1);
echo $buf->toUtf8(); // Ahello
```

### Reading &amp; Writing

[](#reading--writing)

```
$buf = Buffer::alloc(4);
$buf->writeInt32BE(0x12345678, 0);
echo dechex($buf->readInt32BE(0)); // 12345678
```

License
-------

[](#license)

MIT

###  Health Score

50

—

FairBetter than 95% of packages

Maintenance89

Actively maintained with recent releases

Popularity27

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity59

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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 ~220 days

Total

5

Last Release

57d ago

Major Versions

0.2.0 → 1.0.02026-03-20

PHP version history (2 changes)0.1.0PHP ^8.1

1.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/3df9851b05573ab236b96118bf83edd2c6a8f50a41a6372f2d0c8241de2dd56a?d=identicon)[alexander.busse](/maintainers/alexander.busse)

---

Top Contributors

[![AlexanderBuzz](https://avatars.githubusercontent.com/u/102560752?v=4)](https://github.com/AlexanderBuzz "AlexanderBuzz (9 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/hardcastle-buffer/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.0k](/packages/laravel-framework)[ramsey/uuid

A PHP library for generating and working with universally unique identifiers (UUIDs).

12.6k745.0M4.0k](/packages/ramsey-uuid)[brick/money

Money and currency library

1.9k41.8M155](/packages/brick-money)[illuminate/database

The Illuminate Database package.

2.8k54.9M11.6k](/packages/illuminate-database)[flow-php/etl

PHP ETL - Extract Transform Load - Abstraction

378604.0k102](/packages/flow-php-etl)[illuminate/validation

The Illuminate Validation package.

18838.2M1.7k](/packages/illuminate-validation)

PHPackages © 2026

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