PHPackages                             comely-io/buffer-php - 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. comely-io/buffer-php

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

comely-io/buffer-php
====================

Arbitrary bytes buffer in PHP

0.1.17(3y ago)212.7k—0%3MITPHPPHP ^8.1

Since Jun 12Pushed 3y ago1 watchersCompare

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

READMEChangelogDependenciesVersions (17)Used By (3)

Buffer PHP
==========

[](#buffer-php)

Buffer for PHP strings (ByteArray)

Prerequisites
-------------

[](#prerequisites)

- PHP 8.0+
- GMP extension enabled

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

[](#installation)

`composer require comely-io/buffer-php`

Buffer
------

[](#buffer)

### Constructors

[](#constructors)

MethodDescriptionfromBase16Initialize buffer using Base16/Hexadecimal encoded stringfromBase64Initialize buffer from Base64 encoded stringfromByteArrayInitialize buffer from byte arrayfromBinaryInitialize buffer from array of binary encoded bytes\_\_constructCreates a new buffer instance from given argumentFixed-length Buffers
--------------------

[](#fixed-length-buffers)

### Methods

[](#methods)

MethodDescriptionlenGet length/size of buffer in bytesrawGet existing bytes in buffer as stringbyteArrayReturns an indexed Array comprised of every byte's position on ASCII tablecopyCreates a copy of buffer from given start and/or up to lengthequalsCompares buffer bytes with another buffer or stringreadCreates a [ByteReader](#bytereader) instancehashCreates a [ByteDigest](#bytedigest) instanceswitchEndianessConverts endianess of entire buffer between big and little endiansdumpBuffer information as an ArrayapplyFnApplies a function/callback to existing buffer creating a new buffer instance as resulttoBase16Encodes the buffer as Base16/HexadecimaltoBase64Encodes the buffer in Base64toBinaryEncodes the buffer into an indexed Array where each index is binary representation of byte (1s and 0s)checkSizeChecks if buffer is comprised of exactly same number of bytes as in argument, throws `LengthException` otherwiseWriteable Buffers
-----------------

[](#writeable-buffers)

All the methods from fixed-length buffers above, and also:

### Methods

[](#methods-1)

MethodDescriptioncleanFlush any existing data in bufferreadOnlyPuts buffer in Read-only state; Nothing further can be appended to itwritablePuts buffer in writable stateisWritableReturn booleanappendAppend bytes to end of bufferprependPrepend bytes to start of bufferprependUInt8Prepends a single byte integerappendUInt8Appends a single byte integerappendUInt16LEAppends 2 byte integer in little endian byte orderappendUInt16BEAppends 2 byte integer in big endian byte orderappendUInt32LEAppends 4 byte integer in little endian byte orderappendUInt32BEAppends 4 byte integer in big endian byte orderappendUInt64LEAppends 8 byte integer in little endian byte orderappendUInt64BEAppends 8 byte integer in big endian byte orderByteReader
----------

[](#bytereader)

For systematically reading bytes from buffer in order. Useful for serialization and un-serialization of data (i.e. Bitcoin blocks and transactions)

### Methods

[](#methods-2)

MethodDescriptionignoreUnderflowIf invoked, `ByteReaderUnderflowException` will not be thrown if required number of bytes are not presentisEndreturn boolean if end of buffer has been reachedlenLength of buffer in bytesposCurrent position/index at byte in bufferresetResets position index to 0firstResets position index to 0, then reads N number of bytes from start of bufferlookBehindReads last N bytes previously read (does NOT update internal pointer)lookAheadReads next N bytes but does NOT updates internal pointernextReads next N bytes while updating the pointerreadUInt8Reads and converts next 1 byte as UInt8readUInt16LEReads and converts next 2 bytes as UInt16 from little endian byte orderreadUInt16BEReads and converts next 2 bytes as UInt16 from big endian byte orderreadUInt32LEReads and converts next 4 bytes as UInt32 from little endian byte orderreadUInt32BEReads and converts next 4 bytes as UInt32 from big endian byte orderreadUInt64LEReads and converts next 8 bytes as UInt64 from little endian byte orderreadUInt64BEReads and converts next 8 bytes as UInt64 from big endian byte ordersetPointerSets internal reading pointer to specified byteremainingRetrieved all remaining bytes in buffer (does NOT update internal pointer)ByteDigest
----------

[](#bytedigest)

Applies hash function to bytes in buffer and returns digest bytes.

Check PHP.net [hash\_algos()](https://www.php.net/hash_algos)and [hash\_hmac\_algos()](https://www.php.net/hash_hmac_algos) for list of available/supported algorithms.

### Methods

[](#methods-3)

MethodDescriptiontoStringIf invoked before any other method, all hash functions will return `string` instead of new buffer instancehashApplies specified hash algorithm times N iterations and returns X numbers of bytes from digesthmacApplies HMAC hash functionpbkdf2Applies PBKDF2 hash functionmd5Applies `md5` hash functionsha1Applies `SHA1` hash functionsha256Applies `SHA256` hash functionsha512Applies `SHA512` hash functionripeMd160Applies `ripeMd160` hash function

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community12

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 ~43 days

Recently: every ~10 days

Total

16

Last Release

1157d ago

PHP version history (2 changes)0.1.0PHP ^8.0

0.1.8PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11485189?v=4)[M. Furqan Siddiqui](/maintainers/furqansiddiqui)[@furqansiddiqui](https://github.com/furqansiddiqui)

---

Top Contributors

[![furqansiddiqui](https://avatars.githubusercontent.com/u/11485189?v=4)](https://github.com/furqansiddiqui "furqansiddiqui (29 commits)")

### Embed Badge

![Health badge](/badges/comely-io-buffer-php/health.svg)

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

PHPackages © 2026

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