Download the PHP package react/promise-stream without Composer

On this page you can find all versions of the php package react/promise-stream. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package promise-stream

PromiseStream

CI status installs on Packagist

The missing link between Promise-land and Stream-land for ReactPHP.

Table of Contents

Usage

This lightweight library consists only of a few simple functions. All functions reside under the React\Promise\Stream namespace.

The below examples refer to all functions with their fully-qualified names like this:

As of PHP 5.6+ you can also import each required function into your code like this:

Alternatively, you can also use an import statement similar to this:

buffer()

The buffer(ReadableStreamInterface<string> $stream, ?int $maxLength = null): PromiseInterface<string> function can be used to create a Promise which will be fulfilled with the stream data buffer.

The promise will be fulfilled with a string of all data chunks concatenated once the stream closes.

The promise will be fulfilled with an empty string if the stream is already closed.

The promise will be rejected with a RuntimeException if the stream emits an error.

The promise will be rejected with a RuntimeException if it is cancelled.

The optional $maxLength argument defaults to no limit. In case the maximum length is given and the stream emits more data before the end, the promise will be rejected with an OverflowException.

first()

The first(ReadableStreamInterface|WritableStreamInterface $stream, string $event = 'data'): PromiseInterface<mixed> function can be used to create a Promise which will be fulfilled once the given event triggers for the first time.

The promise will be fulfilled with a mixed value of whatever the first event emitted or null if the event does not pass any data. If you do not pass a custom event name, then it will wait for the first "data" event. For common streams of type ReadableStreamInterface<string>, this means it will be fulfilled with a string containing the first data chunk.

The promise will be rejected with a RuntimeException if the stream emits an error – unless you're waiting for the "error" event, in which case it will be fulfilled.

The promise will be rejected with a RuntimeException once the stream closes – unless you're waiting for the "close" event, in which case it will be fulfilled.

The promise will be rejected with a RuntimeException if the stream is already closed.

The promise will be rejected with a RuntimeException if it is cancelled.

all()

The all(ReadableStreamInterface|WritableStreamInterface $stream, string $event = 'data'): PromiseInterface<array> function can be used to create a Promise which will be fulfilled with an array of all the event data.

The promise will be fulfilled with an array once the stream closes. The array will contain whatever all events emitted or null values if the events do not pass any data. If you do not pass a custom event name, then it will wait for all the "data" events. For common streams of type ReadableStreamInterface<string>, this means it will be fulfilled with a string[] array containing all the data chunk.

The promise will be fulfilled with an empty array if the stream is already closed.

The promise will be rejected with a RuntimeException if the stream emits an error.

The promise will be rejected with a RuntimeException if it is cancelled.

unwrapReadable()

The unwrapReadable(PromiseInterface<ReadableStreamInterface<T>> $promise): ReadableStreamInterface<T> function can be used to unwrap a Promise which will be fulfilled with a ReadableStreamInterface<T>.

This function returns a readable stream instance (implementing ReadableStreamInterface<T>) right away which acts as a proxy for the future promise resolution. Once the given Promise will be fulfilled with a ReadableStreamInterface<T>, its data will be piped to the output stream.

If the given promise is either rejected or fulfilled with anything but an instance of ReadableStreamInterface, then the output stream will emit an error event and close:

The given $promise SHOULD be pending, i.e. it SHOULD NOT be fulfilled or rejected at the time of invoking this function. If the given promise is already settled and does not fulfill with an instance of ReadableStreamInterface, then you will not be able to receive the error event.

You can close() the resulting stream at any time, which will either try to cancel() the pending promise or try to close() the underlying stream.

unwrapWritable()

The unwrapWritable(PromiseInterface<WritableStreamInterface<T>> $promise): WritableStreamInterface<T> function can be used to unwrap a Promise which will be fulfilled with a WritableStreamInterface<T>.

This function returns a writable stream instance (implementing WritableStreamInterface<T>) right away which acts as a proxy for the future promise resolution. Any writes to this instance will be buffered in memory for when the promise will be fulfilled. Once the given Promise will be fulfilled with a WritableStreamInterface<T>, any data you have written to the proxy will be forwarded transparently to the inner stream.

If the given promise is either rejected or fulfilled with anything but an instance of WritableStreamInterface, then the output stream will emit an error event and close:

The given $promise SHOULD be pending, i.e. it SHOULD NOT be fulfilled or rejected at the time of invoking this function. If the given promise is already settled and does not fulfill with an instance of WritableStreamInterface, then you will not be able to receive the error event.

You can close() the resulting stream at any time, which will either try to cancel() the pending promise or try to close() the underlying stream.

Install

The recommended way to install this library is through Composer. New to Composer?

This project follows SemVer. This will install the latest supported version:

See also the CHANGELOG for details about version upgrades.

This project aims to run on any platform and thus does not require any PHP extensions and supports running on legacy PHP 5.3 through current PHP 8+ and HHVM. It's highly recommended to use the latest supported PHP version for this project.

Tests

To run the test suite, you first need to clone this repo and then install all dependencies through Composer:

To run the test suite, go to the project root and run:

License

MIT, see LICENSE file.


All versions of promise-stream with dependencies

PHP Build Version
Package Version
Requires php Version >=5.3
react/stream Version ^1.0 || ^0.7 || ^0.6 || ^0.5 || ^0.4.6
react/promise Version ^3 || ^2.1 || ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package react/promise-stream contains the following files

Loading the files please wait ....