2017 © Pedro Peláez
 

library stream

PHP stream library

image

phasty/stream

PHP stream library

  • Thursday, February 11, 2016
  • by dedestr
  • Repository
  • 1 Watchers
  • 0 Stars
  • 7,230 Installations
  • PHP
  • 3 Dependents
  • 0 Suggesters
  • 3 Forks
  • 2 Open issues
  • 7 Versions
  • 6 % Grown

The README.md

Stream

This component is wrapper for different kind of php streams, (*1)

Usage

Classes of this package allow you to deal with such streams as files, sockets, pipes, i/o-streams and so on with ability to use them in non-blocking manner:, (*2)

use Phasty\Stream\Stream;
use Phasty\Stream\StreamSet;
use Phasty\Stream\Timer;

// use wrapper for STDIN
$readStream = new Stream(STDIN);
// streamset allows you work with different streams at sames time tih interraptions for timers
$streamSet = StreamSet::instance();
$streamSet->addReadStream($readStream);
$readStream->on("data", function($event) use ($streamSet) {
    $data = $event->getData();
    if (trim($data) === "q") {
        $streamSet->stop();
        return;
    }
    echo "you wrote: " . $event->getData();
});
$timer = new Timer(2, 0, function() { 
    echo "Now: " . date("H:i:s"), "\n";
});
$streamSet->addTimer($timer);
$streamSet->listen();
echo "exiting\n";

You will get something like this:, (*3)

Now: 20:52:11
dawd
you wrote: dawd
Now: 20:52:13
q
exiting

The Versions

11/02 2016

dev-master

9999999-dev

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream

11/02 2016

0.2.2

0.2.2.0

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream

20/11 2015

0.2.1

0.2.1.0

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream

23/10 2015

0.1.1

0.1.1.0

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream

23/10 2015

0.2.0

0.2.0.0

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream

28/07 2014

0.1.x-dev

0.1.9999999.9999999-dev

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream

28/07 2014

0.1

0.1.0.0

PHP stream library

  Sources   Download

The Requires

 

by Dmitry Cheremnykh

php stream