mpyw/streamable-console

Call interactive artisan command using arbitrary stream
111 4
Install
composer require mpyw/streamable-console
Latest Version:v1.2.1
PHP:^8.2
License:MIT
Last Updated:Jul 14, 2026
Links: GitHub  ·  Packagist
Maintainer: mpyw

Streamable Console Build Status Coverage Status

Call interactive artisan command using arbitrary stream.

Requirements

[!NOTE] Older versions have outdated dependency requirements. If you cannot prepare the latest environment, please refer to past releases.

Installing

composer require mpyw/streamable-console

Usage

Using Stream

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class QuizCommand extends Command
{
    protected $signature = 'example:quiz';

    /**
     * @return int
     */
    public function handle(): int
    {
        // We need to type "no" and press Enter to pass
        if ($this->confirm('Is one plus one equals to three?', true)) {
            return 1;
        }
        
        return 0;
    }
}
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Mpyw\StreamableConsole\Streamable;

class RunCommand extends Command
{
    use Streamable;

    protected $signature = 'example:run';

    /**
     * @return int
     */
    public function handle(): int
    {
        // Type "no" and press Enter
        return $this->usingInputStream("no\n")->call('example:quiz');
    }
}

Using Infinite Input (yes command emulation)

<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;

class QuizCommand extends Command
{
    protected $signature = 'example:quiz';

    /**
     * @return int
     */
    public function handle(): int
    {
        // We need to type "no" and press Enter to pass at least for three times
        if ($this->confirm('Is one plus one equals to three?', true)) {
            return 1;
        }
        if ($this->confirm('Is one plus one equals to three?', true)) {
            return 1;
        }
        if ($this->confirm('Is one plus one equals to three?', true)) {
            return 1;
        }
        
        return 0;
    }
}
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Mpyw\StreamableConsole\Streamable;

class RunCommand extends Command
{
    use Streamable;

    protected $signature = 'example:run';

    /**
     * @return int
     */
    public function handle(): int
    {
        // Infinitely type "no" and press Enter
        return $this->usingInfiniteInput("no\n")->call('example:quiz');
    }
}

Note that you can use yes() as an alias of usingInfiniteInput().

Related Packages

shiftonelabs/laravel-sqs-fifo-queue

Adds a Laravel queue driver for Amazon SQS FIFO queues.

6,984,654 154
zizaco/entrust

This package provides a flexible way to add Role-based Permissions to Laravel. S...

5,357,778 6,005
darsain/laravel-console

Browser console for Laravel Framework.

57,246 167
zizaco/testcases-laravel

Some classes to help write tests for laravel 4 applications

50,506 46
leroy-merlin-br/mongolid-laravel

Easy, powerful and ultrafast MongoDB ODM for Laravel.

28,579 237