NoccyLabs

NoccyLabs develops open source libraries and software. With many projects ongoing, this organization contains public content repositories, as well as software and components considered stable.

noccylabs/react-shell (0.1.0.5)

Published 2026-05-31 19:40:58 +00:00 by noccy

Installation

{
	"repositories": [{
			"type": "composer",
			"url": "https://dev.noccylabs.info/api/packages/noccylabs/composer"
		}
	]
}
composer require noccylabs/react-shell:0.1.0.5

About this package

A friendy interactive shell library for ReactPH

An interactive Unicode-aware shell for ReactPHP

Installing

$ composer require noccylabs/react-shell:@dev

Features

  • Interactive line-editing including arrow keys, home, end, delete and all the commodities you are used to.
  • Automatic scrollback history, to avoid having to retype commands.
  • Input is edited on a single scrolling line.
  • Mostly Unicode-aware, meaning it will not have a nervous breakdown if you try to enter (single-width LTR) unicode characters.

Example

$shell = new NoccyLabs\React\Shell\Shell();

// Emitted whenever the prompt is fully redrawn, or redrawPrompt() is manually
// invoked. This is a good place to update a live prompt.
$shell->on('prompt', function () use ($shell) { 
    $shell->setPrompt(date("H:i:s> ")); 
});
// Emitted whenever a line is entered. The input is already parsed into tokens
// using str_getcsv, respecting double quotes and escape sequeneces.
$shell->on('input', function (array $input) use ($shell) {
    $shell->write("You entered: ".join(" ", $input)."\n");
});

// The shell is an OutputStream, so you can write to it! Doing so will hide the
// prompt, write the output, and then redraw the prompt. This means you don't
// have to care whether the prompt is visible as long as your output is written
// to the shell!
$shell->write("Hello World!\n\n");

// So, this works:
React\EventLoop\Loop::addPeriodicTimer(5, function () use ($shell) {
    $shell->write(date(DATE_ATOM)."\n");
});

Dependencies

Dependencies

ID Version
react/react ^1.4

Development Dependencies

ID Version
phpstan/phpstan ^1.10
phpunit/phpunit ^11.0

Keywords

reactphp shell
Details
Composer
2026-05-31 19:40:58 +00:00
3
NoccyLabs
GPL-3.0-or-later
18 KiB
Assets (1)
Versions (1) View all
0.1.0.5 2026-05-31