2017 © Pedro Peláez
 

library stream

model a sequence of data elements made available over time

image

willwashburn/stream

model a sequence of data elements made available over time

  • Tuesday, March 15, 2016
  • by willwashburn
  • Repository
  • 1 Watchers
  • 2 Stars
  • 6,374 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 60 % Grown

The README.md

Stream :rowboat: Travis Packagist Packagist MIT License

model a sequence of data elements made available over time, (*1)

Usage

Write and read (or peek) from a string of characters., (*2)

$stream = new \WillWashburn\Stream\Stream();
$stream->write('foo');

$stream->read(3); //foo

$stream->write('bar');
$stream->write('bang');

$stream->read(4); // barb
$stream->peek(3); // ang
$stream->read(3); // ang

I mostly use this when buffering responses from curl requests., (*3)

```PHP, (*4)

$stream = new WillWashburn\Stream\Stream;, (*5)

curl_setopt($ch, CURLOPT_WRITEFUNCTION, function ($ch, $str) use (& $stream, $url) {, (*6)

$stream->write($str);

try {
    // do something with the stream
    $characters = $stream->read(100);

    // tell curl to stop the transfer when we find what we're looking for
    if(strpos($characters,'string im looking for') !==false) {
        return -1;
    }
}
catch (StreamBufferTooSmallException $e) {
    // The buffer ended, so keep getting more
    return strlen($str);
}

//  We return -1 to abort the transfer when we have enough buffered
return -1;

});, (*7)

```, (*8)

Installation

Use composer, (*9)

composer require willwashburn/stream, (*10)

Alternatively, add "willwashburn/stream": "~1.0.0" to your composer.json, (*11)

Change Log

  • v1.0.0 - Basic stream model

The Versions

15/03 2016

dev-master

9999999-dev https://github.com/willwashburn/stream

model a sequence of data elements made available over time

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

read stream peek streamable

15/03 2016

v1.0.0

1.0.0.0 https://github.com/willwashburn/stream

model a sequence of data elements made available over time

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

read stream peek streamable