PHPackages                             jordanbrauer/un-stow - 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. jordanbrauer/un-stow

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

jordanbrauer/un-stow
====================

Offers a nice &amp; powerful OOP and/or FP interface for PHP's `pack` and `unpack` functions.

951[1 issues](https://github.com/jordanbrauer/un-stow/issues)PHPCI failing

Since Oct 14Pushed 6y agoCompare

[ Source](https://github.com/jordanbrauer/un-stow)[ Packagist](https://packagist.org/packages/jordanbrauer/un-stow)[ RSS](/packages/jordanbrauer-un-stow/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependenciesVersions (1)Used By (0)

(Un)Stow
========

[](#unstow)

Offers a nice &amp; powerful OOP and/or FP interface for PHP's `pack` and `unpack` functions.

Install
-------

[](#install)

Install with Composer

```
$ composer require jordanbrauer/un-stow
```

Examples
--------

[](#examples)

Below are a few basic examples of how to use this library.

### Hello World

[](#hello-world)

Simple "Hello World!" example for packing (`stow`) and unpacking (`unstow`) hexadecimal data.

```
stow('48656C6C6F20576F726C6421')->hexNibbleHigh('*')->close();
# = (string) Hello World!

unstow('Hello World!')->hexNibbleHigh('*', 'hello_world')->open();
# = (array) [
#     'hello_world' => 48656C6C6F20576F726C6421,
# ],
```

### GIF Header

[](#gif-header)

Even though we have other methods of checking for GIF image data now, this serves as a good example of how `unstow` works for unpacking binary data to read headers.

```
$stream = fopen('./tests/Portal.gif', 'rb');
$bytes = fread($stream, 20);

fclose($stream);

$gifHeader = unstow($bytes)
    ->spacePaddedString(6, 'version')
    ->unsignedChar(2, 'width')
    ->unsignedChar(2, 'height')
    ->unsignedChar(1, 'flag')
    ->nullFill(11)
    ->unsignedChar(1, 'aspect')
    ->open();
```

### Reusing Packers

[](#reusing-packers)

With this library you are able to create "template" packers and unpackers which have a predefined pattern and can accept arbitrary data to pack/unpack.

#### Object-Oriented Method

[](#object-oriented-method)

To re-use a packer in an OOP way, simply omit the bytes from your constructor and chain your format method calls to create your pattern. Next you can pass arbitrary data to the `load` method on and call `close`/`open` to process the data according to the format.

*E.g.*,

```
$packer = stow()
    ->unsignedShort('', Stow::BIG_ENDIAN_16_BIT)
    ->unsignedShort('', Stow::LITTLE_ENDIAN_16_BIT)
    ->signedChar('*');

echo $packer->load(0x1234, 0x5678, 65, 66)->close();
```

#### Functional Method

[](#functional-method)

The functional method is quite similar to the object-oriented way, except two small differences.

1. After chaining all your format method calls, finish it off by calling the `standby` method.
    - This method will return a closure that accepts a set of variadic arguments of arbitrary data.
2. No need to call the `open`/`close` methods: the closure simply returns the packed/unpacked data!

*E.g.*,

```
$packer = stow()
    ->unsignedShort('', Stow::BIG_ENDIAN_16_BIT)
    ->unsignedShort('', Stow::LITTLE_ENDIAN_16_BIT)
    ->signedChar('*')
    ->standby();

echo $packer(0x1234, 0x5678, 65, 66);
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance18

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 94.1% 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/867c1f6d15ff437167c0d7467b16da89095218d52e19716fbf9155497d100615?d=identicon)[jordanbrauer](/maintainers/jordanbrauer)

---

Top Contributors

[![jordanbrauer](https://avatars.githubusercontent.com/u/18744334?v=4)](https://github.com/jordanbrauer "jordanbrauer (16 commits)")[![peter279k](https://avatars.githubusercontent.com/u/9021747?v=4)](https://github.com/peter279k "peter279k (1 commits)")

---

Tags

binarydependency-lessfunctionallibrarymicromodernobject-orientedphp

### Embed Badge

![Health badge](/badges/jordanbrauer-un-stow/health.svg)

```
[![Health](https://phpackages.com/badges/jordanbrauer-un-stow/health.svg)](https://phpackages.com/packages/jordanbrauer-un-stow)
```

PHPackages © 2026

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