You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[](https://packagist.org/packages/clue/stdio-react)
5
5
6
6
Async, event-driven and UTF-8 aware console input & output (STDIN, STDOUT) for
7
-
truly interactive CLI applications, built on top of [ReactPHP](https://reactphp.org).
7
+
truly interactive CLI applications, built on top of [ReactPHP](https://reactphp.org/).
8
8
9
9
You can use this library to build truly interactive and responsive command
10
10
line (CLI) applications, that immediately react when the user types in
@@ -18,18 +18,18 @@ without requiring any extensions or special installation.
18
18
*[Support us](#support-us)
19
19
*[Quickstart example](#quickstart-example)
20
20
*[Usage](#usage)
21
-
*[Stdio](#stdio)
22
-
*[Output](#output)
23
-
*[Input](#input)
24
-
*[Prompt](#prompt)
25
-
*[Echo](#echo)
26
-
*[Input buffer](#input-buffer)
27
-
*[Cursor](#cursor)
28
-
*[History](#history)
29
-
*[Autocomplete](#autocomplete)
30
-
*[Keys](#keys)
31
-
*[Bell](#bell)
32
-
*[Readline](#readline)
21
+
*[Stdio](#stdio)
22
+
* [Output](#output)
23
+
* [Input](#input)
24
+
* [Prompt](#prompt)
25
+
* [Echo](#echo)
26
+
* [Input buffer](#input-buffer)
27
+
* [Cursor](#cursor)
28
+
* [History](#history)
29
+
* [Autocomplete](#autocomplete)
30
+
* [Keys](#keys)
31
+
* [Bell](#bell)
32
+
*[~~Readline~~](#readline)
33
33
*[Pitfalls](#pitfalls)
34
34
*[Install](#install)
35
35
*[Tests](#tests)
@@ -51,8 +51,11 @@ Let's take these projects to the next level together! 🚀
51
51
Once [installed](#install), you can use the following code to present a prompt in a CLI program:
52
52
53
53
```php
54
-
$stdio = new Stdio();
54
+
<?php
55
55
56
+
require __DIR__ . '/vendor/autoload.php';
57
+
58
+
$stdio = new Clue\React\Stdio\Stdio();
56
59
$stdio->setPrompt('Input > ');
57
60
58
61
$stdio->on('data', function ($line) use ($stdio) {
@@ -76,7 +79,7 @@ It is responsible for orchestrating the input and output streams
76
79
by registering and forwarding the corresponding events.
77
80
78
81
```php
79
-
$stdio = new Stdio();
82
+
$stdio = new Clue\React\Stdio\Stdio();
80
83
```
81
84
82
85
This class takes an optional `LoopInterface|null $loop` parameter that can be used to
@@ -567,7 +570,9 @@ enable or disable emitting the BELL signal when using a disabled function:
567
570
$stdio->setBell(false);
568
571
```
569
572
570
-
### Readline
573
+
### ~~Readline~~
574
+
575
+
> Deprecated since v2.3.0, see [`Stdio`](#stdio) instead.
571
576
572
577
The deprecated `Readline` class is responsible for reacting to user input and
573
578
presenting a prompt to the user. It does so by reading individual bytes from the
@@ -630,7 +635,7 @@ ob_start(function ($chunk) use ($stdio) {
630
635
631
636
## Install
632
637
633
-
The recommended way to install this library is [through Composer](https://getcomposer.org).
638
+
The recommended way to install this library is [through Composer](https://getcomposer.org/).
634
639
[New to Composer?](https://getcomposer.org/doc/00-intro.md)
635
640
636
641
This project follows [SemVer](https://semver.org/).
@@ -645,7 +650,7 @@ See also the [CHANGELOG](CHANGELOG.md) for details about version upgrades.
645
650
This project aims to run on any platform and thus does not require any PHP
646
651
extensions and supports running on legacy PHP 5.3 through current PHP 8+ and
647
652
HHVM.
648
-
It's *highly recommended to use PHP 7+* for this project.
653
+
It's *highly recommended to use the latest supported PHP version* for this project.
649
654
650
655
Internally, it will use the `ext-mbstring` to count and measure string sizes.
651
656
If this extension is missing, then this library will use a slighty slower Regex
@@ -660,22 +665,19 @@ Input line editing is handled entirely within this library and does not rely on
660
665
Installing `ext-readline` is entirely optional.
661
666
662
667
Note that *Microsoft Windows is not supported*.
663
-
Due to platform inconsistencies, PHP does not provide support for reading from
664
-
standard console input without blocking.
668
+
Due to platform constraints, PHP does not provide support for reading from
669
+
standard console input without blocking on Windows.
665
670
Unfortunately, until the underlying PHP feature request is implemented (which
666
671
is unlikely to happen any time soon), there's little we can do in this library.
667
-
A work-around for this remains unknown.
668
-
Your only option would be to entirely
669
-
[disable interactive input for Microsoft Windows](https://github.com/clue/psocksd/commit/c2f2f90ffc8ebf8233839ba2f3553f2698930125).
670
-
However this package does work on [`Windows Subsystem for Linux`](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)
671
-
(or WSL) without issues. We suggest [installing WSL](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)
672
+
However, this package does work on Windows Subsystem for Linux (or WSL) without
673
+
issues. We suggest [installing WSL](https://msdn.microsoft.com/en-us/commandline/wsl/install_guide)
672
674
when you want to run this package on Windows.
673
675
See also [#18](https://github.com/clue/reactphp-stdio/issues/18) for more details.
674
676
675
677
## Tests
676
678
677
679
To run the test suite, you first need to clone this repo and then install all
0 commit comments