PHP 클래스 Cake\Console\ConsoleOutput

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 prompts By defining styles with addStyle() you can create custom console styles. ### Using styles in output You can format console output using tags with the name of the style to apply. From inside a shell object $this->out('Overwrite: 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.
파일 보기 프로젝트 열기: cakephp/cakephp 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_backgroundColors array background colors used in colored output.
$_foregroundColors array text colors used in colored output.
$_options string formatting options for colored output
$_output resource File handle for output.
$_outputAs integer The current output type. Manipulated with ConsoleOutput::outputAs();
$_styles array You can modify these styles with ConsoleOutput::styles()

공개 메소드들

메소드 설명
__construct ( string $stream = 'php://stdout' ) Construct the output object.
__destruct ( ) Clean up and close handles
outputAs ( integer | null $type = null ) : integer | null Get/Set the output type to use. The output type how formatting tags are treated.
styleText ( string $text ) : string Apply styling to text.
styles ( string | null $style = null, array | boolean | null $definition = null ) : mixed Get the current styles offered, or append new ones in.
write ( string | array $message, integer $newlines = 1 ) : integer | boolean Outputs a single or multiple messages to stdout or stderr. If no parameters are passed, outputs just a newline.

보호된 메소드들

메소드 설명
_replaceTags ( array $matches ) : string Replace tags with color codes.
_write ( string $message ) : integer | boolean Writes a message to the output stream.

메소드 상세

__construct() 공개 메소드

Checks for a pretty console environment. Ansicon and ConEmu allows pretty consoles on windows, and is supported.
public __construct ( string $stream = 'php://stdout' )
$stream string The identifier of the stream to write output to.

__destruct() 공개 메소드

Clean up and close handles
public __destruct ( )

_replaceTags() 보호된 메소드

Replace tags with color codes.
protected _replaceTags ( array $matches ) : string
$matches array An array of matches to replace.
리턴 string

_write() 보호된 메소드

Writes a message to the output stream.
protected _write ( string $message ) : integer | boolean
$message string Message to write.
리턴 integer | boolean The number of bytes returned from writing to output.

outputAs() 공개 메소드

Get/Set the output type to use. The output type how formatting tags are treated.
public outputAs ( integer | null $type = null ) : integer | null
$type integer | null The output type to use. Should be one of the class constants.
리턴 integer | null Either null or the value if getting.

styleText() 공개 메소드

Apply styling to text.
public styleText ( string $text ) : string
$text string Text with styling tags.
리턴 string String with color codes added.

styles() 공개 메소드

### Get a style definition $output->styles('error'); ### Get all the style definitions $output->styles(); ### Create or modify an existing style $output->styles('annoy', ['text' => 'purple', 'background' => 'yellow', 'blink' => true]); ### Remove a style $this->output->styles('annoy', false);
public styles ( string | null $style = null, array | boolean | null $definition = null ) : mixed
$style string | null The style to get or create.
$definition array | boolean | null The array definition of the style to change or create a style or false to remove a style.
리턴 mixed If you are getting styles, the style or null will be returned. If you are creating/modifying styles true will be returned.

write() 공개 메소드

Outputs a single or multiple messages to stdout or stderr. If no parameters are passed, outputs just a newline.
public write ( string | array $message, integer $newlines = 1 ) : integer | boolean
$message string | array A string or an array of strings to output
$newlines integer Number of newlines to append
리턴 integer | boolean The number of bytes returned from writing to output.

프로퍼티 상세

$_backgroundColors 보호되어 있는 정적으로 프로퍼티

background colors used in colored output.
protected static array $_backgroundColors
리턴 array

$_foregroundColors 보호되어 있는 정적으로 프로퍼티

text colors used in colored output.
protected static array $_foregroundColors
리턴 array

$_options 보호되어 있는 정적으로 프로퍼티

formatting options for colored output
protected static string $_options
리턴 string

$_output 보호되어 있는 프로퍼티

File handle for output.
protected resource $_output
리턴 resource

$_outputAs 보호되어 있는 프로퍼티

The current output type. Manipulated with ConsoleOutput::outputAs();
protected int $_outputAs
리턴 integer

$_styles 보호되어 있는 정적으로 프로퍼티

You can modify these styles with ConsoleOutput::styles()
protected static array $_styles
리턴 array