clue/stdio-react
ReactPHP-based STDIO stream wrapper for non-blocking access to STDIN/STDOUT/STDERR. Enables event-driven CLI apps with readable and writable streams, integrating terminal input/output into the ReactPHP loop for async command-line tools.
spatie/async or reactphp/react) for non-blocking operations.Symfony/Console lacks these features natively.ReadableStreamInterface/WritableStreamInterface, enabling seamless integration with Laravel’s event-driven pipelines (e.g., logging streams, file I/O, or HTTP clients like Guzzle).ext-readline: Avoids PHP’s extension dependency, improving portability (e.g., Docker, serverless, or headless environments).Symfony/Console input handling for async workflows (e.g., php artisan my:command --interactive).reactphp/react + laravel-queues).beyondcode/laravel-websockets).Console component by wrapping Stdio in a custom Input/Output interface (see Pitfalls for edge cases).await syntax (e.g., React\Async\await). Laravel TPMs must upskill or document async patterns for devs.isatty() checks).filesystem facade or redis).ServiceProvider or Artisan integration (must be manually bootstrapped).Symfony/Console’s QuestionHelper for mixed-mode apps.reactphp/react) or Laravel’s async/await (e.g., spatie/async)? The package works with both but requires different bootstrapping.Ctrl+C)?React\EventLoop\StreamSelectLoop::getInstance() with in-memory streams.)React\Stream\ThroughStream?spatie/async for async/await support (if not using pure ReactPHP).composer require reactphp/react clue/stdio-react
Stdio in Symfony\Component\Console\Input\StreamableInputInterface).spatie/async + clue/stdio-react for async CLI.React\EventLoop\Factory.Stdio (e.g., php artisan migrate:fresh --interactive).use Clue\React\Stdio\Stdio;
use React\EventLoop\Factory;
$loop = Factory::create();
$stdio = new Stdio($loop);
$stdio->on('data', fn($line) => $loop->stop());
$stdio->setPrompt('Confirm? [y/N] ');
$loop->run();
Symfony\Component\Console\Command to use Stdio for async parts:
protected function execute(InputInterface $input, OutputInterface $output): int {
$stdio = new Stdio();
$stdio->pipe($output); // Bridge to Symfony Output
// Use $stdio for async input...
}
Stdio + ReactPHP, replacing Symfony/Console entirely.React\Async\await to avoid blocking DB queries during input.laravel-queues and use Stdio for progress updates.React\EventLoop\Timer\TimerInterface events for async workflows.Stdio output to Guzzle\Psr7\Stream for async API calls.React\Stream\ProcessStream to bridge Stdio with system processes.bootstrap/app.php):
$loop = React\EventLoop\Factory::create();
$loop->run();
spatie/async to integrate with Laravel’s container.Stdio to Laravel’s container:
$app->singleton(Stdio::class, fn() => new Stdio($loop));
Symfony\Component\Console\Command with a custom async handler:
use React\Promise\PromiseInterface;
class AsyncCommand extends Command {
public function handle(): PromiseInterface {
return $this->stdio->promise()
->then(fn($input) => $this->processInput($input));
}
}
ext-readline dependency issues.React\Debug\Debug).setRawMode()) may require cleanup in finally blocks.Monolog with React\Stream\WritableStreamInterface for async logs.React\EventLoop\TimerInterface for latency tracking.Stdio with Eloquent").Symfony/Console if TTY is unavailable.React\EventLoop\Signal to catch SIGINT/SIGTERM for clean exits.How can I help you explore Laravel packages today?