2017 © Pedro Peláez
 

library stream

PHP streams and filtering made easy.

image

krak/stream

PHP streams and filtering made easy.

  • Friday, April 21, 2017
  • by ragboyjr
  • Repository
  • 1 Watchers
  • 1 Stars
  • 1,014 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 1 Open issues
  • 2 Versions
  • 51 % Grown

The README.md

Stream

This library provides a simple abstraction over php streams and filters enabling developers to manipulate streams with extreme ease., (*1)

Installation

Install with composer at krak/stream, (*2)

Usage

This example shows kind of a kitchen sink example of what filters are available and how to utilize them., (*3)

<?php

use Krak\Stream;
use Krak\Crypto;

$key = random_bytes(16);
$crypt = new Crypto\OpenSSLCrypt($key);

$src = Stream\fromStr('abc def ghi jkl');
$dst = Stream\toOutput();
Stream\pipe($src, [
    Stream\uppercase(), // utilizes string.toupper filter
    Stream\chunkFilter(function($chunk) {
        return str_replace('ABC', 'XYZ', $chunk);
    }),
    Stream\chunkFilter('str_rot13'), // performs rot13 on stream
    Stream\hex(), // performs bin2hex
    Stream\encrypt($crypt),
    Stream\base64Encode(),

    // below are the inverse functions of above which will undo the transformations

    Stream\base64Decode(),
    Stream\decrypt($crypt),
    Stream\unhex(),
    Stream\createFilter('string.rot13'), // creates a filter from a registered php filter
    Stream\chunkFilter(function($chunk) {
        return str_replace('XYZ', 'ABC', $chunk);
    }),
    Stream\lowercase(),
], $dst);

The output of this would simply be: abc def ghi jkl., (*4)

The Versions

21/04 2017

dev-master

9999999-dev

PHP streams and filtering made easy.

  Sources   Download

MIT

The Requires

 

The Development Requires

filter pipe stream php-stream php_user_filter stream-filter

21/04 2017

v0.1.0

0.1.0.0

PHP streams and filtering made easy.

  Sources   Download

MIT

The Requires

 

The Development Requires

filter pipe stream php-stream php_user_filter stream-filter