Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Hold on, we're currently generating a fresh version of this report
Generated on May 10, 2024 via composer

react/stream v1.3.0

Event-driven readable and writable streams for non-blocking I/O in ReactPHP
Package summary
Share
0
issues
1
license
3
MIT
Package created
7 Jul 2012
Version published
16 Jun 2023
Maintainers
5
Total deps
3
Direct deps
2
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
3 Packages, Including:
evenement/evenement@v3.0.2
react/event-loop@v1.5.0
react/stream@v1.3.0
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

2
All Dependencies CSV
β“˜ This is a list of react/stream 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
evenement/evenementv3.0.24.6 kBMIT
prod
react/event-loopv1.5.039.55 kBMIT
prod

Visualizations

Frequently Asked Questions

What does react/stream do?

React/Stream is a powerful PHP package that offers an API for working with readable and writable streams, allowing efficient processing of large amounts of data for non-blocking I/O. It facilitates the utilization of large data structures like multi-gigabyte file downloads without having to store everything in memory at once, providing an interface more suited for async, non-blocking I/O. This package is part of the ReactPHP project.

How do you use react/stream?

To utilize React/Stream, you first need to install the package via composer. Use the following command in your project directory:

composer require react/stream

After this, you can start working with the Stream package.

A basic usage example that writes 'Hello World' to stdout:

$loop = React\EventLoop\Factory::create();

$stream = new React\Stream\WritableResourceStream(fopen('php://stdout', 'w'), $loop);
$stream->write('Hello World');

$loop->run();

You can listen to events on the stream like 'data', 'end', 'error', and 'close':

$readable->on('data', function ($data) {
    echo 'Received: ' . $data;
});

$readable->on('end', function () {
    echo 'Connection ended';
});

$readable->on('error', function (Exception $e) {
    echo 'Error: ' . $e->getMessage();
});

$readable->on('close', function () {
    echo 'Connection closed';
});

Piping between readable and writable streams is possible and it can be useful for cloning data or building processing chains:

$readable->pipe($writable);

Remember to always handle the stream events in order to effectively work with non-blocking I/O.

Where are the react/stream docs?

The documentation for React/Stream can be found within the package's GitHub repository. The README.MD file in the root of this repository serves as the main source of documentation and includes detailed information about streams, interfaces, and event semantics, as well as examples. For additional information about ReactPHP and related packages, you can refer to ReactPHP's website.