W3cubDocs

/Symfony 2.8

Symfony\Component\Console\Style\SymfonyStyle

class SymfonyStyle extends OutputStyle

Output decorator helpers for the Symfony Style Guide.

Constants

MAX_LINE_LENGTH

Methods

__construct(InputInterface $input, OutputInterface $output)
newLine(int $count = 1)

Add newline(s).

ProgressBar createProgressBar(int $max)
write(string|array $messages, bool $newline = false, $type = self::OUTPUT_NORMAL)

Writes a message to the output.

writeln(string|array $messages, $type = self::OUTPUT_NORMAL)

Writes a message to the output and adds a newline at the end.

setVerbosity(int $level)

Sets the verbosity of the output.

from OutputStyle
int getVerbosity()

Gets the current verbosity of the output.

from OutputStyle
setDecorated(bool $decorated)

Sets the decorated flag.

from OutputStyle
bool isDecorated()

Gets the decorated flag.

from OutputStyle
setFormatter(OutputFormatterInterface $formatter)

Sets output formatter.

from OutputStyle
OutputFormatterInterface getFormatter()

Returns current output formatter instance.

from OutputStyle
block(string|array $messages, string|null $type = null, string|null $style = null, string $prefix = ' ', bool $padding = false)

Formats a message as a block of text.

title(string $message)

Formats a command title.

section(string $message)

Formats a section title.

listing(array $elements)

Formats a list.

text(string|array $message)

Formats informational text.

comment($message)

{@inheritdoc}

success(string|array $message)

Formats a success result bar.

error(string|array $message)

Formats an error result bar.

warning(string|array $message)

Formats an warning result bar.

note(string|array $message)

Formats a note admonition.

caution(string|array $message)

Formats a caution admonition.

table(array $headers, array $rows)

Formats a table.

string ask(string $question, string|null $default = null, callable|null $validator = null)

Asks a question.

string askHidden(string $question, callable|null $validator = null)

Asks a question with the user input hidden.

bool confirm(string $question, bool $default = true)

Asks for confirmation.

string choice(string $question, array $choices, string|int|null $default = null)

Asks a choice question.

progressStart(int $max)

Starts the progress output.

progressAdvance(int $step = 1)

Advances the progress output X steps.

progressFinish()

Finishes the progress output.

string askQuestion(Question $question)

Details

public __construct(InputInterface $input, OutputInterface $output)

Parameters

InputInterface $input
OutputInterface $output

public newLine(int $count = 1)

Add newline(s).

Parameters

int $count The number of newlines

public ProgressBar createProgressBar(int $max)

Parameters

int $max

Return Value

ProgressBar

public write(string|array $messages, bool $newline = false, $type = self::OUTPUT_NORMAL)

Writes a message to the output.

Parameters

string|array $messages The message as an array of lines or a single string
bool $newline Whether to add a newline
$type

public writeln(string|array $messages, $type = self::OUTPUT_NORMAL)

Writes a message to the output and adds a newline at the end.

Parameters

string|array $messages The message as an array of lines of a single string
$type

public setVerbosity(int $level)

Sets the verbosity of the output.

Parameters

int $level The level of verbosity (one of the VERBOSITY constants)

public int getVerbosity()

Gets the current verbosity of the output.

Return Value

int The current level of verbosity (one of the VERBOSITY constants)

public setDecorated(bool $decorated)

Sets the decorated flag.

Parameters

bool $decorated Whether to decorate the messages

public bool isDecorated()

Gets the decorated flag.

Return Value

bool true if the output will decorate messages, false otherwise

public setFormatter(OutputFormatterInterface $formatter)

Sets output formatter.

Parameters

OutputFormatterInterface $formatter

public OutputFormatterInterface getFormatter()

Returns current output formatter instance.

public block(string|array $messages, string|null $type = null, string|null $style = null, string $prefix = ' ', bool $padding = false)

Formats a message as a block of text.

Parameters

string|array $messages The message to write in the block
string|null $type The block type (added in [] on first line)
string|null $style The style to apply to the whole block
string $prefix The prefix for the block
bool $padding Whether to add vertical padding

public title(string $message)

Formats a command title.

Parameters

string $message

public section(string $message)

Formats a section title.

Parameters

string $message

public listing(array $elements)

Formats a list.

Parameters

array $elements

public text(string|array $message)

Formats informational text.

Parameters

string|array $message

public comment($message)

{@inheritdoc}

Parameters

$message

public success(string|array $message)

Formats a success result bar.

Parameters

string|array $message

public error(string|array $message)

Formats an error result bar.

Parameters

string|array $message

public warning(string|array $message)

Formats an warning result bar.

Parameters

string|array $message

public note(string|array $message)

Formats a note admonition.

Parameters

string|array $message

public caution(string|array $message)

Formats a caution admonition.

Parameters

string|array $message

public table(array $headers, array $rows)

Formats a table.

Parameters

array $headers
array $rows

public string ask(string $question, string|null $default = null, callable|null $validator = null)

Asks a question.

Parameters

string $question
string|null $default
callable|null $validator

Return Value

string

public string askHidden(string $question, callable|null $validator = null)

Asks a question with the user input hidden.

Parameters

string $question
callable|null $validator

Return Value

string

public bool confirm(string $question, bool $default = true)

Asks for confirmation.

Parameters

string $question
bool $default

Return Value

bool

public string choice(string $question, array $choices, string|int|null $default = null)

Asks a choice question.

Parameters

string $question
array $choices
string|int|null $default

Return Value

string

public progressStart(int $max)

Starts the progress output.

Parameters

int $max Maximum steps (0 if unknown)

public progressAdvance(int $step = 1)

Advances the progress output X steps.

Parameters

int $step Number of steps to advance

public progressFinish()

Finishes the progress output.

public string askQuestion(Question $question)

Parameters

Question $question

Return Value

string

© 2004–2016 Fabien Potencier
Licensed under the MIT License.
http://api.symfony.com/2.8/Symfony/Component/Console/Style/SymfonyStyle.html