PHPackages                             fzaninotto/streamer - 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. fzaninotto/streamer

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

fzaninotto/streamer
===================

Object-oriented API to PHP streams

0.0.1(13y ago)26417.3k31[4 issues](https://github.com/fzaninotto/Streamer/issues)1MITPHPPHP &gt;=5.3.0

Since Jul 2Pushed 9y ago1 watchersCompare

[ Source](https://github.com/fzaninotto/Streamer)[ Packagist](https://packagist.org/packages/fzaninotto/streamer)[ Docs](https://github.com/fzaninotto/Streamer)[ RSS](/packages/fzaninotto-streamer/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (1)

Streamer
========

[](#streamer)

Streamer is an Object-Oriented API for PHP streams.

Why should I use Streams?
-------------------------

[](#why-should-i-use-streams)

A stream is a flow of bytes from one container to the other. You already use streams a lot in PHP, for instance each time you load a file into memory (`file_get_contents()`). You should explicitly use streams each time that:

- You need to access data from a container, but you don't know the size of this container (e.g. reading from STDIN, or a web service using streaming)
- You need to start processing data from a container before the whole transfer is finished (e.g. start zipping a file before it's all in memory)
- You need to save time and memory

What is Streamer?
-----------------

[](#what-is-streamer)

PHP has a very elaborate stream API ; unfortunately, it uses functions for most stream operations (except for wrappers - go figure). Streamer is a generic library focusing on offering an object-oriented API to streams, and only that.

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

[](#installation)

Streamer is published on [packagist.org](http://packagist.org/packages/fzaninotto/Streamer), so you can add it to your `composer.json` file for an easy installation:

```
composer require fzaninotto/Streamer
```

or

```
{
    "require": {
        "fzaninotto/Streamer": "0.0.1"
    }
}
```

Example
-------

[](#example)

```
