1. Go to this page and download the library: Download clue/stdio-react library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
clue / stdio-react example snippets
o = new Clue\React\Stdio\Stdio();
$stdio->setPrompt('Input > ');
$stdio->on('data', function ($line) use ($stdio) {
$line = rtrim($line, "\r\n");
$stdio->write('Your input: ' . $line . PHP_EOL);
if ($line === 'quit') {
$stdio->end();
}
});
$stdio->on('data', function ($line) {
if ($line === "start\n") {
doSomething();
}
});
$stdio->on('data', function ($line) {
$line = rtrim($line, "\r\n");
if ($line === "start") {
doSomething();
}
});
$stdio->pipe($logger);
$stdio->setPrompt('Input: ');
$stdio->setPrompt('');
assert($stdio->getPrompt() === '');
$stdio->setEcho(false);
$stdio->setEcho('*');
$stdio->setEcho(true);
$stdio->addInput('hello');
$stdio->setInput('lastpass');
$buffer = $stdio->getInput();
$stdio->setMove(false);
$stdio->setMove(true);
$position = $stdio->getCursorPosition();
$cell = $stdio->getCursorCell();
$stdio->moveCursorTo(0);
$stdio->moveCursorBy(-1);
$stdio->on('data', function ($line) use ($stdio) {
$line = rtrim($line);
$all = $stdio->listHistory();
// skip empty line and duplicate of previous line
if ($line !== '' && $line !== end($all)) {
$stdio->addHistory($line);
}
});
$limit = getenv('HISTSIZE');
if ($limit === '' || $limit < 0) {
// empty string or negative value means unlimited
$stdio->limitHistory(null);
} elseif ($limit !== false) {
// apply any other value if given
$stdio->limitHistory($limit);
}
ob_start(function ($chunk) use ($stdio) {
// forward write event to Stdio instead
$stdio->write($chunk);
// discard data from normal output handling
return '';
}, 1);
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.