Download the PHP package clue/stream-filter without Composer

On this page you can find all versions of the php package clue/stream-filter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.


After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package stream-filter


CI status installs on Packagist

A simple and modern approach to stream filtering in PHP

Table of contents


PHP's stream filtering system is great!

It offers very powerful stream filtering options and comes with a useful set of built-in filters. These filters can be used to easily and efficiently perform various transformations on-the-fly, such as:

But let's face it: Its API is difficult to work with and its documentation is subpar. This combined means its powerful features are often neglected.

This project aims to make these features more accessible to a broader audience.

Support us

We invest a lot of time developing, maintaining and updating our awesome open-source projects. You can help us sustain this high-quality of our work by becoming a sponsor on GitHub. Sponsors get numerous benefits in return, see our sponsoring page for details.

Let's take these projects to the next level together! 🚀


This lightweight library consists only of a few simple functions. All functions reside under the Clue\StreamFilter namespace.

The below examples refer to all functions with their fully-qualified names like this:

As of PHP 5.6+ you can also import each required function into your code like this:

Alternatively, you can also use an import statement similar to this:


The append(resource<stream> $stream, callable $callback, int $read_write = STREAM_FILTER_ALL): resource<stream filter> function can be used to append a filter callback to the given stream.

Each stream can have a list of filters attached. This function appends a filter to the end of this list.

If the given filter can not be added, it throws an Exception.

The $stream can be any valid stream resource, such as:

The $callback should be a valid callable function which accepts an individual chunk of data and should return the updated chunk:

As such, you can also use native PHP functions or any other callable:

If the $callback accepts invocation without parameters, then this signature will be invoked once ending (flushing) the filter:

Note: Legacy PHP versions (PHP < 5.4) do not support passing additional data from the end signal handler if the stream is being closed.

If your callback throws an Exception, then the filter process will be aborted. In order to play nice with PHP's stream handling, the Exception will be transformed to a PHP warning instead:

The optional $read_write parameter can be used to only invoke the $callback when either writing to the stream or only when reading from the stream:

This function returns a filter resource which can be passed to remove().

Note that once a filter has been added to stream, the stream can no longer be passed to stream_select() (and family).

Warning: stream_select(): cannot cast a filtered stream on this system in {file} on line {line}

This is due to limitations of PHP's stream filter support, as it can no longer reliably tell when the underlying stream resource is actually ready. As an alternative, consider calling stream_select() on the unfiltered stream and then pass the unfiltered data through the fun() function.


The prepend(resource<stream> $stream, callable $callback, int $read_write = STREAM_FILTER_ALL): resource<stream filter> function can be used to prepend a filter callback to the given stream.

Each stream can have a list of filters attached. This function prepends a filter to the start of this list.

If the given filter can not be added, it throws an Exception.

This function returns a filter resource which can be passed to remove().

Except for the position in the list of filters, this function behaves exactly like the append() function. For more details about its behavior, see also the append() function.


The fun(string $filter, mixed $parameters = null): callable function can be used to create a filter function which uses the given built-in $filter.

PHP comes with a useful set of built-in filters. Using fun() makes accessing these as easy as passing an input string to filter and getting the filtered output string.

Please note that not all filter functions may be available depending on installed PHP extensions and the PHP version in use. In particular, HHVM may not offer the same filter functions or parameters as Zend PHP. Accessing an unknown filter function will result in a RuntimeException:

Some filters may accept or require additional filter parameters – most filters do not require filter parameters. If given, the optional $parameters argument will be passed to the underlying filter handler as-is. In particular, note how not passing this parameter at all differs from explicitly passing a null value (which many filters do not accept). Please refer to the individual filter definition for more details. For example, the string.strip_tags filter can be invoked like this:

Under the hood, this function allocates a temporary memory stream, so it's recommended to clean up the filter function after use. Also, some filter functions (in particular the zlib compression filters) may use internal buffers and may emit a final data chunk on close. The filter function can be closed by invoking without any arguments:

The filter function must not be used anymore after it has been closed. Doing so will result in a RuntimeException:

Note: If you're using the zlib compression filters, then you should be wary about engine inconsistencies between different PHP versions and HHVM. These inconsistencies exist in the underlying PHP engines and there's little we can do about this in this library. Our test suite contains several test cases that exhibit these issues. If you feel some test case is missing or outdated, we're happy to accept PRs! :)


The remove(resource<stream filter> $filter): bool function can be used to remove a filter previously added via prepend().


The recommended way to install this library is through Composer. New to Composer?

This project follows SemVer. This will install the latest supported version:

See also the CHANGELOG for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's highly recommended to use the latest supported PHP version for this project. Older PHP versions may suffer from a number of inconsistencies documented above.


To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

To run the test suite, go to the project root and run:


This project is released under the permissive MIT license.

Did you know that I offer custom development services and issuing invoices for sponsorships of releases and for contributions? Contact me (@clue) for details.

All versions of stream-filter with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package clue/stream-filter contains the following files

Loading the files please wait ....