Constants

NORMAL

NORMAL = 0

Color indices

BLACK

BLACK = 1

RED

RED = 2

GREEN

GREEN = 3

YELLOW

YELLOW = 4

BLUE

BLUE = 5

MAGENTA

MAGENTA = 6

CYAN

CYAN = 7

WHITE

WHITE = 8

GRAY

GRAY = 9

BOLD_RED

BOLD_RED = 10

BOLD_GREEN

BOLD_GREEN = 11

BOLD_YELLOW

BOLD_YELLOW = 12

BOLD_BLUE

BOLD_BLUE = 13

BOLD_MAGENTA

BOLD_MAGENTA = 14

BOLD_CYAN

BOLD_CYAN = 15

BOLD_WHITE

BOLD_WHITE = 16

Properties

$width

$width : integer

Console character width

Type

integer

$indent

$indent : string

Console indentation

Type

string

$response

$response : string

Console response body

Type

string

$commands

$commands : array

Commands

Type

array

$header

$header : string

Console header

Type

string

$headerSent

$headerSent : boolean

Flag for if console header has been sent

Type

boolean

$footer

$footer : string

Console footer

Type

string

$helpColors

$helpColors : array

Help colors

Type

array

$server

$server : array

SERVER array

Type

array

$env

$env : array

ENV array

Type

array

$colorMap

$colorMap : array

Color map of ansi values

Type

array

Methods

__construct()

__construct(integer  $width = 80, string  $indent = '    ') 

Instantiate a new console object

Parameters

integer $width
string $indent

setWidth()

setWidth(integer  $width) : \Pop\Console\Console

Set the wrap width of the console object

Parameters

integer $width

Returns

\Pop\Console\Console

setIndent()

setIndent(string  $indent = null) : \Pop\Console\Console

Set the indentation of the console object

Parameters

string $indent

Returns

\Pop\Console\Console

setHeader()

setHeader(string  $header) : \Pop\Console\Console

Set the console header

Parameters

string $header

Returns

\Pop\Console\Console

setFooter()

setFooter(string  $footer) : \Pop\Console\Console

Set the console footer

Parameters

string $footer

Returns

\Pop\Console\Console

setHeaderSent()

setHeaderSent(boolean  $headerSent = true) : \Pop\Console\Console

Set the console header sent flag

Parameters

boolean $headerSent

Returns

\Pop\Console\Console

setHelpColors()

setHelpColors(integer  $color1, integer  $color2 = null, integer  $color3 = null) : \Pop\Console\Console

Set the console help colors

Parameters

integer $color1
integer $color2
integer $color3

Returns

\Pop\Console\Console

getWidth()

getWidth() : integer

Get the wrap width of the console object

Returns

integer

getIndent()

getIndent() : string

Get the indentation of the console object

Returns

string

getHeader()

getHeader(boolean  $formatted = false) : string

Get the console header

Parameters

boolean $formatted

Returns

string

getFooter()

getFooter(boolean  $formatted = false) : string

Get the console footer

Parameters

boolean $formatted

Returns

string

getHeaderSent()

getHeaderSent() : boolean

Get the console header sent flag

Returns

boolean

getHelpColors()

getHelpColors() : array

Get the console help colors

Returns

array

getServer()

getServer(string  $key = null) : string|array

Get a value from $_SERVER, or the whole array

Parameters

string $key

Returns

string|array

getEnv()

getEnv(string  $key = null) : string|array

Get a value from $_ENV, or the whole array

Parameters

string $key

Returns

string|array

addCommands()

addCommands(array  $commands) : \Pop\Console\Console

Add commands

Parameters

array $commands

Returns

\Pop\Console\Console

getCommands()

getCommands() : array

Get commands

Returns

array

getCommand()

getCommand(string  $command) : \Pop\Console\Command

Get a command

Parameters

string $command

Returns

\Pop\Console\Command

hasCommand()

hasCommand(string  $command) : boolean

Check if the console object has a command

Parameters

string $command

Returns

boolean

getCommandsFromRoutes()

getCommandsFromRoutes(\Pop\Router\Match\Cli  $routeMatch, string  $scriptName = null) : array

Get commands from routes

Parameters

\Pop\Router\Match\Cli $routeMatch
string $scriptName

Returns

array

addCommandsFromRoutes()

addCommandsFromRoutes(\Pop\Router\Match\Cli  $routeMatch, string  $scriptName = null) : \Pop\Console\Console

Add commands from routes

Parameters

\Pop\Router\Match\Cli $routeMatch
string $scriptName

Returns

\Pop\Console\Console

help()

help(string  $command = null) : string

Get a help

Parameters

string $command

Returns

string

colorize()

colorize(string  $string, integer  $fg = null, integer  $bg = null) : string

Colorize a string for output

Parameters

string $string
integer $fg
integer $bg

Returns

string

prompt()

prompt(string  $prompt, array  $options = null, boolean  $caseSensitive = false, integer  $length = 500, boolean  $withHeaders = true) : string

Get input from the prompt

Parameters

string $prompt
array $options
boolean $caseSensitive
integer $length
boolean $withHeaders

Returns

string

append()

append(string  $text = null, boolean  $newline = true) : \Pop\Console\Console

Append a string of text to the response body

Parameters

string $text
boolean $newline

Returns

\Pop\Console\Console

write()

write(string  $text = null, boolean  $newline = true, boolean  $withHeaders = true) : \Pop\Console\Console

Write a string of text to the response body and send the response

Parameters

string $text
boolean $newline
boolean $withHeaders

Returns

\Pop\Console\Console

send()

send(boolean  $withHeaders = true) : \Pop\Console\Console

Send the response

Parameters

boolean $withHeaders

Returns

\Pop\Console\Console

displayHelp()

displayHelp() : void

Display console help

clear()

clear() : void

Clear the console

getColorCode()

getColorCode(integer  $color, string  $type = 'foreground') : mixed

Get the color code from the color map

Parameters

integer $color
string $type

Returns

mixed

formatTemplate()

formatTemplate(string  $template) : string

Format header or footer template

Parameters

string $template

Returns

string