PHPackages                             gravitymedia/stream - 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. gravitymedia/stream

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

gravitymedia/stream
===================

Stream is an object oriented library for reading and writing binary streams in PHP.

6891PHP

Since Jul 11Pushed 10y ago1 watchersCompare

[ Source](https://github.com/GravityMedia/Stream)[ Packagist](https://packagist.org/packages/gravitymedia/stream)[ RSS](/packages/gravitymedia-stream/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

Stream
======

[](#stream)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8740dc7fa29c3334f46e1edac00fc310ce74661d6535015da6ac740b956e6042/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f677261766974796d656469612f73747265616d2e737667)](https://packagist.org/packages/gravitymedia/stream)[![Software License](https://camo.githubusercontent.com/7e3f58477549394e20bbad589b26c22d88e44405c9a3820b6ab1ac031ea215a1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f677261766974796d656469612f73747265616d2e737667)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/3269456663bdbe739ab086bf8527a390020673b59216c2760453530a4ec6ef80/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f477261766974794d656469612f53747265616d2e737667)](https://travis-ci.org/GravityMedia/Stream)[![Coverage Status](https://camo.githubusercontent.com/c44213a864eb7e8edd51559b35a53a6d014350d252485b1fb6b88900326c3711/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f477261766974794d656469612f53747265616d2e737667)](https://scrutinizer-ci.com/g/GravityMedia/Stream/code-structure)[![Quality Score](https://camo.githubusercontent.com/40da9c3df81af99e4de2a2bb9071216cf6accdd5424a9a38e9a35078268d5f5c/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f477261766974794d656469612f53747265616d2e737667)](https://scrutinizer-ci.com/g/GravityMedia/Stream)[![Total Downloads](https://camo.githubusercontent.com/254f04e52bfd07fe79752216e43cd856d5c543b88166b547870f93b8cf003efc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f677261766974796d656469612f73747265616d2e737667)](https://packagist.org/packages/gravitymedia/stream)[![Dependency Status](https://camo.githubusercontent.com/a8c7fcc5e3a86a9b65d5b36b9f1a016f6a3dc3129fb508c5fa7fa91b68546933/68747470733a2f2f696d672e736869656c64732e696f2f76657273696f6e6579652f642f7068702f677261766974796d656469613a73747265616d2e737667)](https://www.versioneye.com/user/projects/54f76e264f31083e1b0017e2)

Stream is an object oriented library for reading and writing binary streams in PHP.

Requirements
------------

[](#requirements)

This library has the following requirements:

- PHP 5.6+

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

[](#installation)

Install Composer in your project:

```
$ curl -s https://getcomposer.org/installer | php
```

Add the package to your `composer.json` and install it via Composer:

```
$ php composer.phar require gravitymedia/stream
```

Usage
-----

[](#usage)

This is a simple usage example for character streams but is applicable for binary data streams.

```
require 'vendor/autoload.php';

use GravityMedia\Stream\Stream;

// create resource
$resource = fopen('php://temp', 'r+');

// create new stream object
$stream = Stream::fromResource($resource);

// write some data
$stream->write("\x63\x6f\x6e\x74\x65\x6e\x74\x73");

// seek a position
$stream->seek(4);

// print 32 bit unsigned integer
print $stream->readUInt32() . PHP_EOL;

// rewind stream
$stream->rewind();

// print the data previously written
while (!$stream->eof()) {
    print $stream->read(1);
}
print PHP_EOL;

// print position
print $stream->tell() . PHP_EOL;

// rewind stream
$stream->rewind();

// truncate random data
$stream->truncate(7);

// print the truncated data
while (!$stream->eof()) {
    print $stream->read(1);
}
print PHP_EOL;
```

Testing
-------

[](#testing)

Clone this repository, install Composer and all dependencies:

```
$ php composer.phar install
```

Run the test suite:

```
$ php vendor/bin/phing test
```

Generating documentation
------------------------

[](#generating-documentation)

Clone this repository, install Composer and all dependencies:

```
$ php composer.phar install
```

Generate the documentation to the `build/docs` directory:

```
$ php vendor/bin/phing doc
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Credits
-------

[](#credits)

- [Daniel Schröder](https://github.com/pCoLaSD)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 25% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

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://avatars.githubusercontent.com/u/4107232?v=4)[Daniel Schröder](/maintainers/schroedan)[@schroedan](https://github.com/schroedan)

### Embed Badge

![Health badge](/badges/gravitymedia-stream/health.svg)

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

###  Alternatives

[tecnocen/yii2-bootstrap-year-calendar

Yii2 widget for bootstrap-year-calendar plugin

1318.2k](/packages/tecnocen-yii2-bootstrap-year-calendar)[wordpress/ai-provider-for-google

AI Provider for Google for the PHP AI Client SDK. Works as both a Composer package and WordPress plugin.

191.3k](/packages/wordpress-ai-provider-for-google)

PHPackages © 2026

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