Console
in package
Console class
Tags
Table of Contents
- BLACK = 1
- BLUE = 5
- BOLD_BLUE = 13
- BOLD_CYAN = 15
- BOLD_GREEN = 11
- BOLD_MAGENTA = 14
- BOLD_RED = 10
- BOLD_WHITE = 16
- BOLD_YELLOW = 12
- CYAN = 7
- GRAY = 9
- GREEN = 3
- MAGENTA = 6
- NORMAL = 0
- Color indices
- RED = 2
- WHITE = 8
- YELLOW = 4
- $colorMap : array<string|int, mixed>
- Color map of ansi values
- $commands : array<string|int, mixed>
- Commands
- $env : array<string|int, mixed>
- ENV array
- $footer : string
- Console footer
- $header : string
- Console header
- $headerSent : bool
- Flag for if console header has been sent
- $helpColors : array<string|int, mixed>
- Help colors
- $indent : string
- Console indentation
- $response : string
- Console response body
- $server : array<string|int, mixed>
- SERVER array
- $width : int
- Console character width
- __construct() : mixed
- Instantiate a new console object
- addCommand() : Console
- Add a command
- addCommands() : Console
- Add commands
- addCommandsFromRoutes() : Console
- Add commands from routes
- append() : Console
- Append a string of text to the response body
- clear() : void
- Clear the console
- colorize() : string
- Colorize a string for output
- displayHelp() : void
- Display console help
- getCommand() : Command
- Get a command
- getCommands() : array<string|int, mixed>
- Get commands
- getCommandsFromRoutes() : array<string|int, mixed>
- Get commands from routes
- getEnv() : string|array<string|int, mixed>
- Get a value from $_ENV, or the whole array
- getFooter() : string
- Get the console footer
- getHeader() : string
- Get the console header
- getHeaderSent() : bool
- Get the console header sent flag
- getHelpColors() : array<string|int, mixed>
- Get the console help colors
- getIndent() : string
- Get the indentation of the console object
- getServer() : string|array<string|int, mixed>
- Get a value from $_SERVER, or the whole array
- getWidth() : int
- Get the wrap width of the console object
- hasCommand() : bool
- Check if the console object has a command
- help() : string
- Get a help
- prompt() : string
- Get input from the prompt
- send() : Console
- Send the response
- setFooter() : Console
- Set the console footer
- setHeader() : Console
- Set the console header
- setHeaderSent() : Console
- Set the console header sent flag
- setHelpColors() : Console
- Set the console help colors
- setIndent() : Console
- Set the indentation of the console object
- setWidth() : Console
- Set the wrap width of the console object
- write() : Console
- Write a string of text to the response body and send the response
- formatTemplate() : string
- Format header or footer template
- getColorCode() : mixed
- Get the color code from the color map
Constants
BLACK
public
mixed
BLACK
= 1
BLUE
public
mixed
BLUE
= 5
BOLD_BLUE
public
mixed
BOLD_BLUE
= 13
BOLD_CYAN
public
mixed
BOLD_CYAN
= 15
BOLD_GREEN
public
mixed
BOLD_GREEN
= 11
BOLD_MAGENTA
public
mixed
BOLD_MAGENTA
= 14
BOLD_RED
public
mixed
BOLD_RED
= 10
BOLD_WHITE
public
mixed
BOLD_WHITE
= 16
BOLD_YELLOW
public
mixed
BOLD_YELLOW
= 12
CYAN
public
mixed
CYAN
= 7
GRAY
public
mixed
GRAY
= 9
GREEN
public
mixed
GREEN
= 3
MAGENTA
public
mixed
MAGENTA
= 6
NORMAL
Color indices
public
mixed
NORMAL
= ""
RED
public
mixed
RED
= 2
WHITE
public
mixed
WHITE
= 8
YELLOW
public
mixed
YELLOW
= 4
Properties
$colorMap
Color map of ansi values
protected
static array<string|int, mixed>
$colorMap
= ['foreground' => [self::NORMAL => '22;39', self::BLACK => '0;30', self::RED => '0;31', self::GREEN => '0;32', self::YELLOW => '0;33', self::BLUE => '0;34', self::MAGENTA => '0;35', self::CYAN => '0;36', self::WHITE => '0;37', self::GRAY => '1;30', self::BOLD_RED => '1;31', self::BOLD_GREEN => '1;32', self::BOLD_YELLOW => '1;33', self::BOLD_BLUE => '1;34', self::BOLD_MAGENTA => '1;35', self::BOLD_CYAN => '1;36', self::BOLD_WHITE => '1;37'], 'background' => [self::NORMAL => '0;49', self::BLACK => '40', self::RED => '41', self::GREEN => '42', self::YELLOW => '43', self::BLUE => '44', self::MAGENTA => '45', self::CYAN => '46', self::WHITE => '47']]
$commands
Commands
protected
array<string|int, mixed>
$commands
= []
$env
ENV array
protected
array<string|int, mixed>
$env
= []
$footer
Console footer
protected
string
$footer
= null
$header
Console header
protected
string
$header
= null
$headerSent
Flag for if console header has been sent
protected
bool
$headerSent
= false
$helpColors
Help colors
protected
array<string|int, mixed>
$helpColors
= []
$indent
Console indentation
protected
string
$indent
= null
$response
Console response body
protected
string
$response
= null
$server
SERVER array
protected
array<string|int, mixed>
$server
= []
$width
Console character width
protected
int
$width
= 80
Methods
__construct()
Instantiate a new console object
public
__construct([int $width = 80 ][, string $indent = ' ' ]) : mixed
Parameters
- $width : int = 80
- $indent : string = ' '
Return values
mixed —addCommand()
Add a command
public
addCommand(Command $command) : Console
Parameters
- $command : Command
Return values
Console —addCommands()
Add commands
public
addCommands(array<string|int, mixed> $commands) : Console
Parameters
- $commands : array<string|int, mixed>
Return values
Console —addCommandsFromRoutes()
Add commands from routes
public
addCommandsFromRoutes(Cli $routeMatch[, string $scriptName = null ]) : Console
Parameters
- $routeMatch : Cli
- $scriptName : string = null
Return values
Console —append()
Append a string of text to the response body
public
append([string $text = null ][, bool $newline = true ]) : Console
Parameters
- $text : string = null
- $newline : bool = true
Return values
Console —clear()
Clear the console
public
clear() : void
Return values
void —colorize()
Colorize a string for output
public
colorize(string $string[, int $fg = null ][, int $bg = null ]) : string
Parameters
- $string : string
- $fg : int = null
- $bg : int = null
Return values
string —displayHelp()
Display console help
public
displayHelp() : void
Return values
void —getCommand()
Get a command
public
getCommand(string $command) : Command
Parameters
- $command : string
Return values
Command —getCommands()
Get commands
public
getCommands() : array<string|int, mixed>
Return values
array<string|int, mixed> —getCommandsFromRoutes()
Get commands from routes
public
getCommandsFromRoutes(Cli $routeMatch[, string $scriptName = null ]) : array<string|int, mixed>
Parameters
- $routeMatch : Cli
- $scriptName : string = null
Return values
array<string|int, mixed> —getEnv()
Get a value from $_ENV, or the whole array
public
getEnv([string $key = null ]) : string|array<string|int, mixed>
Parameters
- $key : string = null
Return values
string|array<string|int, mixed> —getFooter()
Get the console footer
public
getFooter([bool $formatted = false ]) : string
Parameters
- $formatted : bool = false
Return values
string —getHeader()
Get the console header
public
getHeader([bool $formatted = false ]) : string
Parameters
- $formatted : bool = false
Return values
string —getHeaderSent()
Get the console header sent flag
public
getHeaderSent() : bool
Return values
bool —getHelpColors()
Get the console help colors
public
getHelpColors() : array<string|int, mixed>
Return values
array<string|int, mixed> —getIndent()
Get the indentation of the console object
public
getIndent() : string
Return values
string —getServer()
Get a value from $_SERVER, or the whole array
public
getServer([string $key = null ]) : string|array<string|int, mixed>
Parameters
- $key : string = null
Return values
string|array<string|int, mixed> —getWidth()
Get the wrap width of the console object
public
getWidth() : int
Return values
int —hasCommand()
Check if the console object has a command
public
hasCommand(string $command) : bool
Parameters
- $command : string
Return values
bool —help()
Get a help
public
help([string $command = null ]) : string
Parameters
- $command : string = null
Return values
string —prompt()
Get input from the prompt
public
prompt(string $prompt[, array<string|int, mixed> $options = null ][, bool $caseSensitive = false ][, int $length = 500 ][, bool $withHeaders = true ]) : string
Parameters
- $prompt : string
- $options : array<string|int, mixed> = null
- $caseSensitive : bool = false
- $length : int = 500
- $withHeaders : bool = true
Return values
string —send()
Send the response
public
send([bool $withHeaders = true ]) : Console
Parameters
- $withHeaders : bool = true
Return values
Console —setFooter()
Set the console footer
public
setFooter(string $footer) : Console
Parameters
- $footer : string
Return values
Console —setHeader()
Set the console header
public
setHeader(string $header) : Console
Parameters
- $header : string
Return values
Console —setHeaderSent()
Set the console header sent flag
public
setHeaderSent([bool $headerSent = true ]) : Console
Parameters
- $headerSent : bool = true
Return values
Console —setHelpColors()
Set the console help colors
public
setHelpColors(int $color1[, int $color2 = null ][, int $color3 = null ]) : Console
Parameters
- $color1 : int
- $color2 : int = null
- $color3 : int = null
Return values
Console —setIndent()
Set the indentation of the console object
public
setIndent([string $indent = null ]) : Console
Parameters
- $indent : string = null
Return values
Console —setWidth()
Set the wrap width of the console object
public
setWidth(int $width) : Console
Parameters
- $width : int
Return values
Console —write()
Write a string of text to the response body and send the response
public
write([string $text = null ][, bool $newline = true ][, bool $withHeaders = true ]) : Console
Parameters
- $text : string = null
- $newline : bool = true
- $withHeaders : bool = true
Return values
Console —formatTemplate()
Format header or footer template
protected
formatTemplate(string $template) : string
Parameters
- $template : string
Return values
string —getColorCode()
Get the color code from the color map
protected
getColorCode(int $color[, string $type = 'foreground' ]) : mixed
Parameters
- $color : int
- $type : string = 'foreground'