legionth / line-react
Requires
- php: >=5.3
- react/stream: ^0.4 || ^0.3
Requires (Dev)
- phpunit/phpunit: ^4.8.10||^5.0
- react/event-loop: ^0.4 || ^0.3
This package is auto-updated.
Last update: 2024-12-16 19:53:57 UTC
README
Line reader stream to forward complete lines to a stream.
Table of Contents
Usage
LineReader
The center of this project is the LineReader
class.
This class checks incoming data for an new line delimiter, if the delimeter has been found in the current data chunk the data will be exposed on the stream.
When the new line delimeter isn't found the data chunk,
it will be buffered until a delimiter occures.
The LineReader
is a duplex stream, so a readable and writable stream at the same time.
Checkout examples
how you can use this project.
$ cat words.txt | php examples/readLine.php
This example makes clear what example this project can be used for. Every line with a new line delimiter will put into the readable stream. Every other line without a new line delimiter will be buffered until another occures.
The first parameter of the LineReader
is the custom delimiter.
The default value of this delimiter is PHP_EOL
.
Install
The recommended way to install this library is through Composer. New to Composer?
This will install the latest supported version:
$ composer require legionth/line-react:^0.2
See also the CHANGELOG for details about version upgrades.
License
MIT