Output Object

An instance of an output object Swoft\Console\Output\Output that is used to display information to the console. Command logic, input and output objects can be obtained by function parameters and global functions.

Get Output objects

By method parameters

If you need to use input and output objects, you can define input and output objects on the action command function, and the underlying framework automatically injects objects.

/**
 * Test command
 *
 * @Command(coroutine=true)
 */
class TestCommand
{
    /**
     * @param Input  $input
     * @param Output $output
     *
     * @CommandMapping("test2")
     */
    public function test(Input $input, Output $output)
    {
        // ......
    }
}

Working with global functions

/**
 * Test command
 *
 * @Command(coroutine=true)
 */
class TestCommand
{
    /**
     * @CommandMapping()
     */
    public function demo()
    {
        $input = \input();
        $output = \output();
        // ......
    }
}
/docs/2.x/en/console/output.html
progress-bar