Lines Matching refs:stream

4 message implementation, several stream decorators, and some helpful
13 This package comes with a number of stream implementations and stream
40 Provides a buffer stream that can be written to fill a buffer, and read
43 This stream returns a "hwm" metadata value that tells upstream consumers
44 what the configured high water mark of the stream is, or the maximum
60 entity body fails due to needing to rewind the stream (for example, resulting
61 from a redirect). Data that is read from the remote stream will be buffered in
62 a PHP temp stream so that previously read bytes are cached first in memory,
69 $stream = new Psr7\CachingStream($original);
71 $stream->read(1024);
72 echo $stream->tell();
75 $stream->seek(0);
76 echo $stream->tell();
86 stream becomes too full.
91 // Create an empty stream
92 $stream = Psr7\Utils::streamFor();
94 // Start dropping data when the stream has more than 10 bytes
95 $dropping = new Psr7\DroppingStream($stream, 10);
98 echo $stream; // 0123456789
106 Compose stream implementations based on a hash of functions.
108 Allows for easy testing and extension of a provided stream without needing
115 $stream = Psr7\Utils::streamFor('hi');
116 $fnStream = Psr7\FnStream::decorate($stream, [
117 'rewind' => function () use ($stream) {
119 $stream->rewind();
135 This stream decorator skips the first 10 bytes of the given stream to remove
136 the gzip header, converts the provided stream to a PHP stream resource,
137 then appends the zlib.inflate filter. The stream is then converted back
138 to a Guzzle stream resource to be used as a Guzzle stream.
146 take place on the stream.
151 $stream = new Psr7\LazyOpenStream('/path/to/file', 'r');
154 echo $stream->read(10);
163 LimitStream can be used to read a subset or slice of an existing stream object.
175 $stream = new Psr7\LimitStream($original, 1024, 2048);
176 echo $stream->getSize();
178 echo $stream->tell();
188 multipart/form-data stream.
195 NoSeekStream wraps a stream and does not allow seeking.
217 Provides a read only stream that pumps data from a PHP callable.
227 ## Implementing stream decorators
229 Creating a stream decorator is very easy thanks to the
232 stream. Just `use` the `StreamDecoratorTrait` and implement your custom
236 byte is read from a stream. This could be implemented by overriding the
249 public function __construct(StreamInterface $stream, callable $cb)
251 $this->stream = $stream;
257 $result = $this->stream->read($length);
269 This decorator could be added to any existing stream and used like so:
292 PSR-7 stream as a PHP stream resource.
295 stream from a PSR-7 stream.
300 $stream = GuzzleHttp\Psr7\Utils::streamFor('hello!');
301 $resource = StreamWrapper::getResource($stream);
426 Copy the contents of a stream into another stream until the given number
432 `public static function copyToString(StreamInterface $stream, int $maxLen = -1): string`
434 Copy the contents of a stream into a string until the given number of
440 `public static function hash(StreamInterface $stream, string $algo, bool $rawOutput = false): strin…
442 Calculate a hash of a stream.
444 This method reads the entire stream to calculate a rolling hash, based on
468 `public static function readLine(StreamInterface $stream, int $maxLength = null): string`
470 Read a line from the stream up to the maximum allowed buffer length.
477 Create a new stream based on the input type.
482 - size: Size of the stream.
487 - `string`: Creates a stream object that uses the given string as the contents.
488 - `resource`: Creates a stream object that wraps the given PHP stream resource.
490 stream object will be created that wraps the given iterable. Each time the
491 stream is read from, data from the iterator will fill a buffer and will be
496 the object will be cast to a string and then a stream will be returned that
498 - `NULL`: When `null` is passed, an empty stream object is returned.
499 - `callable` When a callable is passed, a read-only stream object will be
503 stream object that wraps the callable will invoke the callable until the
508 $stream = GuzzleHttp\Psr7\Utils::streamFor('foo');
509 $stream = GuzzleHttp\Psr7\Utils::streamFor(fopen('/path/to/file', 'r'));
517 $stream = GuzzleHttp\Psr7\Utils::streamFor($generator(100));
525 Safely opens a PHP stream resource using a filename.