Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

4 Commits

Repository files navigation

Stream

This library provides a simple abstraction over php streams and filters enabling developers to manipulate streams with extreme ease.

Installation

Install with composer at krak/stream

Usage

This example shows kind of a kitchen sink example of what filters are available and how to utilize them.

<?phpuseKrak\Stream;
useKrak\Crypto;
$key = random_bytes(16);
$crypt = newCrypto\OpenSSLCrypt($key);
$src = Stream\fromStr('abc def ghi jkl');
$dst = Stream\toOutput();
Stream\pipe($src, [
Stream\uppercase(), // utilizes string.toupper filterStream\chunkFilter(function($chunk) {
returnstr_replace('ABC', 'XYZ', $chunk);
}),
Stream\chunkFilter('str_rot13'), // performs rot13 on streamStream\hex(), // performs bin2hexStream\encrypt($crypt),
Stream\base64Encode(),
// below are the inverse functions of above which will undo the transformationsStream\base64Decode(),
Stream\decrypt($crypt),
Stream\unhex(),
Stream\createFilter('string.rot13'), // creates a filter from a registered php filterStream\chunkFilter(function($chunk) {
returnstr_replace('XYZ', 'ABC', $chunk);
}),
Stream\lowercase(),
], $dst);

The output of this would simply be: abc def ghi jkl.

About

PHP streams and filtering made easy.

Topics

Resources

Stars

2 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages