Output object
The output object is an instance of Swoft\Console\Output\Output
that is used to display information to the console. In the command logic, input and output objects can be obtained through function parameters and global functions.
Get the output object
Method parameters
If you need to use input and output objects, you can define input and output objects on the operation command function, and the underlying framework will automatically inject the object.
/**
* Test command
*
* @Command(coroutine=true)
*/
class TestCommand
{
/**
* @param Input $input
* @param Output $output
*
* @CommandMapping("test2")
*/
public function test(Input $input, Output $output)
{
// ......
}
}
Using global functions
/**
* Test command
*
* @Command(coroutine=true)
*/
class TestCommand
{
/**
* @CommandMapping()
*/
public function demo()
{
$input = \input();
$output = \output();
// ......
}
}