abstract class Command implements CommandInterface

Base command.

Traits

Controller helper trait.
Container aware trait.

Properties

protected Container $container Container. from ContainerAwareTrait
protected array $resolved Array of resolved objects and/or references to resolved objects. from ContainerAwareTrait
Application $app from ContainerAwareTrait
CacheManager $cache from ContainerAwareTrait
protected Input $input Input.
protected Output $output Output.
CommandBusInterface $bus from ContainerAwareTrait
Config $config from ContainerAwareTrait
ConnectionManager $database from ContainerAwareTrait
ErrorHandler $errorHandler from ContainerAwareTrait
Event $event from ContainerAwareTrait
FileSystem $fileSystem from ContainerAwareTrait
AuthorizerInterface $authorizer from ContainerAwareTrait
Gatekeeper $gatekeeper from ContainerAwareTrait
Request $request from ContainerAwareTrait
Response $response from ContainerAwareTrait
Routes $routes from ContainerAwareTrait
URLBuilder $urlBuilder from ContainerAwareTrait
I18n $i18n from ContainerAwareTrait
PaginationFactoryInterface $pagination from ContainerAwareTrait
ConnectionManager $redis from ContainerAwareTrait
CryptoManager $crypto from ContainerAwareTrait
Signer $signer from ContainerAwareTrait
Session $session from ContainerAwareTrait
Humanizer $humanizer from ContainerAwareTrait
ValidatorFactory $validator from ContainerAwareTrait
ViewFactory $view from ContainerAwareTrait
Logger $logger from ContainerAwareTrait
protected string $command Command.
protected string $description Command description.

Methods

setContainer(Container $container)

Sets the container instance.

mixed
__get(string $key)

Resolves item from the container using overloading.

nl(int $lines = 1, int $writer = Output::STANDARD)

Writes n newlines to output.

write(string $string, int $writer = Output::STANDARD)

Writes string to output.

error(string $string)

Writes string to output using the error writer.

clear()

Clears the screen.

alert(string $message, string $template = Alert::DEFAULT, int $writer = Output::STANDARD)

Draws an alert.

bell(int $times = 1)

Rings the terminal bell n times.

countdown(int $from = 5)

Counts down from n.

progressBar(int $items, float $minTimeBetweenRedraw = 0.1, string|null $prefix = null)

Draws a progress bar and returns a progress bar instance.

table(array $columnNames, array $rows, int $writer = Output::STANDARD)

Draws a table.

ol(array $items, string $marker = '<yellow>%s</yellow>.', int $writer = Output::STANDARD)

Draws an ordered list.

ul(array $items, string $marker = '<yellow>*</yellow>', int $writer = Output::STANDARD)

Draws an unordered list.

bool
confirm(string $question, string $default = 'n')

Writes question to output and returns boolesn value corresponding to the chosen value.

mixed
question(string $question, mixed $default = null)

Writes question to output and returns user input.

int
select(string $question, array $options)

Prints out a list of options and returns the array key of the chosen value.

mixed
secret(string $question, mixed $default = null, bool $fallback = false)

Writes question to output and returns hidden user input.

__construct(Input $input, Output $output)

Constructor.

string|null
getCommand()

Returns the command.

string
getDescription()

Returns the command description.

array
getArguments()

Returns the command arguments.

Details

in ContainerAwareTrait at line 66
setContainer(Container $container)

Sets the container instance.

Parameters

Container $container Container

in ContainerAwareTrait at line 77
mixed __get(string $key)

Resolves item from the container using overloading.

Parameters

string $key Key

Return Value

mixed

in CommandHelperTrait at line 39
protected nl(int $lines = 1, int $writer = Output::STANDARD)

Writes n newlines to output.

Parameters

int $lines Number of newlines to write
int $writer Output writer

in CommandHelperTrait at line 50
protected write(string $string, int $writer = Output::STANDARD)

Writes string to output.

Parameters

string $string String to write
int $writer Output writer

in CommandHelperTrait at line 60
protected error(string $string)

Writes string to output using the error writer.

Parameters

string $string String to write

in CommandHelperTrait at line 68
protected clear()

Clears the screen.

in CommandHelperTrait at line 80
protected alert(string $message, string $template = Alert::DEFAULT, int $writer = Output::STANDARD)

Draws an alert.

Parameters

string $message Message
string $template Alert template
int $writer Output writer

in CommandHelperTrait at line 90
protected bell(int $times = 1)

Rings the terminal bell n times.

Parameters

int $times Number of times to ring the bell

in CommandHelperTrait at line 100
protected countdown(int $from = 5)

Counts down from n.

Parameters

int $from Number of seconds to count down

in CommandHelperTrait at line 113
protected ProgressBar progressBar(int $items, float $minTimeBetweenRedraw = 0.1, string|null $prefix = null)

Draws a progress bar and returns a progress bar instance.

Parameters

int $items Total number of items
float $minTimeBetweenRedraw Minimum time between redraw in seconds
string|null $prefix Progress bar prefix

Return Value

ProgressBar

in CommandHelperTrait at line 140
protected table(array $columnNames, array $rows, int $writer = Output::STANDARD)

Draws a table.

Parameters

array $columnNames Array of column names
array $rows Array of rows
int $writer Output writer

in CommandHelperTrait at line 152
protected ol(array $items, string $marker = '<yellow>%s</yellow>.', int $writer = Output::STANDARD)

Draws an ordered list.

Parameters

array $items Items
string $marker Item marker
int $writer Output writer

in CommandHelperTrait at line 164
protected ul(array $items, string $marker = '<yellow>*</yellow>', int $writer = Output::STANDARD)

Draws an unordered list.

Parameters

array $items Items
string $marker Item marker
int $writer Output writer

in CommandHelperTrait at line 176
protected bool confirm(string $question, string $default = 'n')

Writes question to output and returns boolesn value corresponding to the chosen value.

Parameters

string $question Question to ask
string $default Default answer

Return Value

bool

in CommandHelperTrait at line 188
protected mixed question(string $question, mixed $default = null)

Writes question to output and returns user input.

Parameters

string $question Question to ask
mixed $default Default if no input is entered

Return Value

mixed

in CommandHelperTrait at line 200
protected int select(string $question, array $options)

Prints out a list of options and returns the array key of the chosen value.

Parameters

string $question Question to ask
array $options Numeric array of options to choose from

Return Value

int

in CommandHelperTrait at line 213
protected mixed secret(string $question, mixed $default = null, bool $fallback = false)

Writes question to output and returns hidden user input.

Parameters

string $question Question to ask
mixed $default Default if no input is entered
bool $fallback Fall back to non-hidden input?

Return Value

mixed

at line 55
__construct(Input $input, Output $output)

Constructor.

Parameters

Input $input Input
Output $output Output

at line 65
string|null getCommand()

Returns the command.

Return Value

string|null

at line 73
string getDescription()

Returns the command description.

Return Value

string

at line 81
array getArguments()

Returns the command arguments.

Return Value

array