abstract class ConsoleCommand extends Command

Base class for all commands

Properties

protected SymfonyStyle $style Style obj reference
protected bool $default Set to true for default command
protected Table $table Table output
protected EventDispatcher $dispatcher Event dispatcher
protected string|null $outputType Output type
protected array $result Command result data

Methods

__construct(string|null $name = null, string|null $description = null)

Constructor

void
setOutputType(string|null $outputType)

Set output type

array
getResult()

Get execution result

boolean
isConsoleOutput()

Return true if output is to console

void
setDispatcher(object $dispatcher)

Set event dispatcher

mixed
executeCommand(InputInterface $input, OutputInterface $output)

Abstract method.

mixed
run(InputInterface $input, OutputInterface $output)

Run method wrapper

void
addRequiredArgument(string $name, string $description = '', mixed|null $default = null)

Add required argument

void
addOptionalArgument(string $name, string $description = '', mixed|null $default = null)

Add optional argument

void
addOptionalOption(string $name, string $description = '', mixed|null $default = null)

Add optional option

mixed
execute(InputInterface $input, OutputInterface $output)

Run console command

Table
table()

Get table obj

void
setDefault(bool $default = true)

Set command as default

bool
isDefault()

Return true if command is default.

void
showTitle(string|null $title = null, string $space = ' ')

Show command title

void
showError(string $message, string $label = 'Error:', string $space = ' ')

Show error message

void
showErrors(string|array $errors, string $label = 'Error:', string $space = ' ')

Show multipel errors

void
showErrorDetails(string|array $details, string $space = ' ')

Show error details

void
checkMark(string $space = ' ')

Show CHECK MARK

void
newLine()

New line

void
showCompleted(string|null $label = null, string $space = ' ')

Show 'done' message

void
writeField(string $label, mixed $value, string $color = 'cyan', string $space = ' ')

Write field

void
writeFieldLn(string $label, mixed $value, string $color = 'cyan', string $space = ' ')

Write field

void
writeLn(string $text, string $space = ' ', string|null $color = null)

Write line

Details

at line 77
__construct(string|null $name = null, string|null $description = null)

Constructor

Parameters

string|null $name
string|null $description

at line 97
void setOutputType(string|null $outputType)

Set output type

Parameters

string|null $outputType

Return Value

void

at line 107
array getResult()

Get execution result

Return Value

array

at line 117
boolean isConsoleOutput()

Return true if output is to console

Return Value

boolean

at line 128
void setDispatcher(object $dispatcher)

Set event dispatcher

Parameters

object $dispatcher

Return Value

void

at line 140
abstract protected mixed executeCommand(InputInterface $input, OutputInterface $output)

Abstract method.

Parameters

InputInterface $input
OutputInterface $output

Return Value

mixed

at line 149
mixed run(InputInterface $input, OutputInterface $output)

Run method wrapper

Parameters

InputInterface $input
OutputInterface $output

Return Value

mixed

at line 175
void addRequiredArgument(string $name, string $description = '', mixed|null $default = null)

Add required argument

Parameters

string $name
string $description
mixed|null $default

Return Value

void

at line 188
void addOptionalArgument(string $name, string $description = '', mixed|null $default = null)

Add optional argument

Parameters

string $name
string $description
mixed|null $default

Return Value

void

at line 201
void addOptionalOption(string $name, string $description = '', mixed|null $default = null)

Add optional option

Parameters

string $name
string $description
mixed|null $default

Return Value

void

at line 213
protected mixed execute(InputInterface $input, OutputInterface $output)

Run console command

Parameters

InputInterface $input
OutputInterface $output

Return Value

mixed

at line 225
Table table()

Get table obj

Return Value

Table

at line 236
void setDefault(bool $default = true)

Set command as default

Parameters

bool $default

Return Value

void

at line 246
bool isDefault()

Return true if command is default.

Return Value

bool

at line 258
void showTitle(string|null $title = null, string $space = ' ')

Show command title

Parameters

string|null $title
string $space

Return Value

void

at line 281
void showError(string $message, string $label = 'Error:', string $space = ' ')

Show error message

Parameters

string $message
string $label
string $space

Return Value

void

at line 296
void showErrors(string|array $errors, string $label = 'Error:', string $space = ' ')

Show multipel errors

Parameters

string|array $errors
string $label
string $space

Return Value

void

at line 315
void showErrorDetails(string|array $details, string $space = ' ')

Show error details

Parameters

string|array $details
string $space

Return Value

void

at line 333
void checkMark(string $space = ' ')

Show CHECK MARK

Parameters

string $space

Return Value

void

at line 343
void newLine()

New line

Return Value

void

at line 355
void showCompleted(string|null $label = null, string $space = ' ')

Show 'done' message

Parameters

string|null $label
string $space

Return Value

void

at line 372
void writeField(string $label, mixed $value, string $color = 'cyan', string $space = ' ')

Write field

Parameters

string $label
mixed $value
string $color
string $space

Return Value

void

at line 389
void writeFieldLn(string $label, mixed $value, string $color = 'cyan', string $space = ' ')

Write field

Parameters

string $label
mixed $value
string $color
string $space

Return Value

void

at line 403
void writeLn(string $text, string $space = ' ', string|null $color = null)

Write line

Parameters

string $text
string $space
string|null $color

Return Value

void