Object wrapper for outputting information from a shell application. Can be connected to any stream resource that can be used with fopen()
Can generate colorized output on consoles that support it. There are a few built in styles
error Error messages.warning Warning messages.info Informational messages.comment Additional text.question Magenta text used for user promptsBy defining styles with addStyle() you can create custom console styles.
You can format console output using tags with the name of the style to apply. From inside a shell object
$this->out('<warning>Overwrite:</warning> foo.php was overwritten.'); This would create orange 'Overwrite:' text, while the rest of the text would remain the normal color. See ConsoleOutput::styles() to learn more about defining your own styles. Nested styles are not supported at this time.
int 2
Color output - Convert known tags in to ANSI color escape codes.
string PHP_EOL
Constant for a newline.
int 1
Plain output - tags will be stripped.
int 0
Raw output constant - no modification of output text.
array<string, int>background colors used in colored output.
array<string, int>text colors used in colored output.
array<string, int>Formatting options for colored output.
resourceFile handle for output.
intThe current output type.
array<string, array>Styles that are available as tags in console output. You can modify these styles with ConsoleOutput::styles()
Construct the output object.
Clean up and close handles
Replace tags with color codes.
Writes a message to the output stream.
Get the output type on how formatting tags are treated.
Gets the current styles offered
Set the output type on how formatting tags are treated.
Sets style.
Apply styling to text.
Gets all the style definitions.
Outputs a single or multiple messages to stdout or stderr. If no parameters are passed, outputs just a newline.
__construct(string $stream = 'php://stdout')
Construct the output object.
Checks for a pretty console environment. Ansicon and ConEmu allows pretty consoles on Windows, and is supported.
string $stream optional The identifier of the stream to write output to.
__destruct()
Clean up and close handles
_replaceTags(array<string, string> $matches): string
Replace tags with color codes.
array<string, string> $matches An array of matches to replace.
string_write(string $message): int
Writes a message to the output stream.
string $message Message to write.
intgetOutputAs(): int
Get the output type on how formatting tags are treated.
intgetStyle(string $style): array
Gets the current styles offered
string $style The style to get.
arraysetOutputAs(int $type): void
Set the output type on how formatting tags are treated.
int $type The output type to use. Should be one of the class constants.
voidInvalidArgumentExceptionsetStyle(string $style, array $definition): void
Sets style.
$output->setStyle('annoy', ['text' => 'purple', 'background' => 'yellow', 'blink' => true]); $this->output->setStyle('annoy', []); string $style The style to set.
array $definition The array definition of the style to change or create..
voidstyleText(string $text): string
Apply styling to text.
string $text Text with styling tags.
stringstyles(): array<string, mixed>
Gets all the style definitions.
array<string, mixed>write(array<string>|string $message, int $newlines = 1): int
Outputs a single or multiple messages to stdout or stderr. If no parameters are passed, outputs just a newline.
array<string>|string $message A string or an array of strings to output
int $newlines optional Number of newlines to append
intbackground colors used in colored output.
array<string, int>text colors used in colored output.
array<string, int>Formatting options for colored output.
array<string, int>File handle for output.
resourceThe current output type.
intStyles that are available as tags in console output. You can modify these styles with ConsoleOutput::styles()
array<string, array>
© 2005–present The Cake Software Foundation, Inc.
Licensed under the MIT License.
CakePHP is a registered trademark of Cake Software Foundation, Inc.
We are not endorsed by or affiliated with CakePHP.
https://api.cakephp.org/4.4/class-Cake.Console.ConsoleOutput.html