2017 © Pedro Peláez
 

library streams

A set of generic stream wrappers

image

icewind/streams

A set of generic stream wrappers

  • Tuesday, April 24, 2018
  • by icewind1991
  • Repository
  • 1 Watchers
  • 2 Stars
  • 132,776 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 3 Open issues
  • 15 Versions
  • 13 % Grown

The README.md

Streams

CI codecov, (*1)

Generic stream wrappers for php., (*2)

CallBackWrapper

A CallBackWrapper can be used to register callbacks on read, write and closing of the stream, it wraps an existing stream and can thus be used for any stream in php, (*3)

The callbacks are passed in the stream context along with the source stream and can be any valid php callable, (*4)

Example

<?php

use \Icewind\Streams\CallBackWrapper;

require('vendor/autoload.php');

// get an existing stream to wrap
$source = fopen('php://temp', 'r+');

// register the callbacks
$stream = CallbackWrapper::wrap($source,
    // read callback
    function ($count) {
        echo "read " . $count . "bytes\n";
    },
    // write callback
    function ($data) {
        echo "wrote '" . $data . "'\n";
    },
    // close callback
    function () {
        echo "stream closed\n";
    });

fwrite($stream, 'some dummy data');

rewind($stream);
fread($stream, 5);

fclose($stream);

Note: due to php's internal stream buffering the $count passed to the read callback will be equal to php's internal buffer size (8192 on default) an not the number of bytes requested by fopen(), (*5)

The Versions

24/04 2018

dev-master

9999999-dev

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

24/04 2018

0.6.1

0.6.1.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

30/01 2018

0.6.0

0.6.0.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

02/12 2016

0.5.2

0.5.2.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

17/11 2016

dev-supress-warning

dev-supress-warning

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

26/10 2016

0.5.1

0.5.1.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

26/10 2016

0.5.0

0.5.0.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

02/06 2016

0.4.1

0.4.1.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

17/03 2016

0.4.0

0.4.0.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

16/03 2016

dev-retry

dev-retry

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

16/03 2016

dev-coveralls-dep

dev-coveralls-dep

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

01/09 2015

0.3.0

0.3.0.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

31/07 2014

0.2

0.2.0.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

24/07 2014

0.1.1

0.1.1.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires

24/07 2014

0.1

0.1.0.0

A set of generic stream wrappers

  Sources   Download

MIT

The Requires

  • php >=5.3

 

The Development Requires