KMP PHP API Reference

Io
in package

Composition class as proxy towards ConsoleIO - basically a shell replacement for inside business logic.

Table of Contents

Properties

$_io  : ConsoleIo

Methods

__construct()  : mixed
abort()  : void
Displays a formatted error message and exits the application with status code 1
comment()  : int|null
Convenience method for out() that wraps message between <comment /> tag
err()  : int|null
Outputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.
helper()  : Helper
Create and render the output for a helper object. If the helper object has not already been loaded, it will be loaded and constructed.
hr()  : void
Outputs a series of minus characters to the standard output, acts as a visual separator.
info()  : int|null
Convenience method for out() that wraps message between <info /> tag
nl()  : string
Returns a single or multiple linefeeds sequences.
out()  : int|null
Outputs a single or multiple messages to stdout. If no parameters are passed outputs just a newline.
overwrite()  : void
Overwrite some already output text.
quiet()  : int|null
Output at all levels.
success()  : int|null
Convenience method for out() that wraps message between <success /> tag
verbose()  : int|null
Output at the verbose level.
warn()  : int|null
Convenience method for err() that wraps message between <warning /> tag

Properties

$_io

protected ConsoleIo $_io

Methods

__construct()

public __construct(ConsoleIo $io) : mixed
Parameters
$io : ConsoleIo

comment()

Convenience method for out() that wraps message between <comment /> tag

public comment([array<string|int, string>|string $message = '' ][, int $newlines = 1 ][, int $level = ConsoleIo::NORMAL ]) : int|null
Parameters
$message : array<string|int, string>|string = ''

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

$level : int = ConsoleIo::NORMAL

The message's output level, see above.

Tags
see
https://book.cakephp.org/4/en/console-commands/input-output.html#creating-output
Return values
int|null

The number of bytes returned from writing to stdout.

err()

Outputs a single or multiple error messages to stderr. If no parameters are passed outputs just a newline.

public err([array<string|int, string>|string $message = '' ][, int $newlines = 1 ]) : int|null
Parameters
$message : array<string|int, string>|string = ''

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

Return values
int|null

The number of bytes returned from writing to stderr.

helper()

Create and render the output for a helper object. If the helper object has not already been loaded, it will be loaded and constructed.

public helper(string $name[, array<string, mixed> $settings = [] ]) : Helper
Parameters
$name : string

The name of the helper to render

$settings : array<string, mixed> = []

Configuration data for the helper.

Return values
Helper

The created helper instance.

info()

Convenience method for out() that wraps message between <info /> tag

public info([array<string|int, string>|string $message = '' ][, int $newlines = 1 ][, int $level = ConsoleIo::NORMAL ]) : int|null
Parameters
$message : array<string|int, string>|string = ''

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

$level : int = ConsoleIo::NORMAL

The message's output level, see above.

Tags
see
https://book.cakephp.org/4/en/console-commands/input-output.html#creating-output
Return values
int|null

The number of bytes returned from writing to stdout.

out()

Outputs a single or multiple messages to stdout. If no parameters are passed outputs just a newline.

public out([array<string|int, string>|string $message = '' ][, int $newlines = 1 ][, int $level = ConsoleIo::NORMAL ]) : int|null

Output levels

There are 3 built-in output level. ConsoleIo::QUIET, ConsoleIo::NORMAL, ConsoleIo::VERBOSE. The verbose and quiet output levels, map to the verbose and quiet output switches present in most shells. Using ConsoleIo::QUIET for a message means it will always display. While using ConsoleIo::VERBOSE means it will only display when verbose output is toggled.

Parameters
$message : array<string|int, string>|string = ''

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

$level : int = ConsoleIo::NORMAL

The message's output level, see above.

Tags
link
https://book.cakephp.org/4/en/console-commands/input-output.html#creating-output
Return values
int|null

The number of bytes returned from writing to stdout.

overwrite()

Overwrite some already output text.

public overwrite(array<string|int, string>|string $message[, int $newlines = 1 ][, int|null $size = null ]) : void

Useful for building progress bars, or when you want to replace text already output to the screen with new text.

Warning You cannot overwrite text that contains newlines.

Parameters
$message : array<string|int, string>|string

The message to output.

$newlines : int = 1

Number of newlines to append.

$size : int|null = null

The number of bytes to overwrite. Defaults to the length of the last message output.

quiet()

Output at all levels.

public quiet(array<string|int, string>|string $message[, int $newlines = 1 ]) : int|null
Parameters
$message : array<string|int, string>|string

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

Return values
int|null

The number of bytes returned from writing to stdout.

success()

Convenience method for out() that wraps message between <success /> tag

public success([array<string|int, string>|string $message = '' ][, int $newlines = 1 ][, int $level = ConsoleIo::NORMAL ]) : int|null
Parameters
$message : array<string|int, string>|string = ''

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

$level : int = ConsoleIo::NORMAL

The message's output level, see above.

Tags
see
https://book.cakephp.org/4/en/console-commands/input-output.html#creating-output
Return values
int|null

The number of bytes returned from writing to stdout.

verbose()

Output at the verbose level.

public verbose(array<string|int, string>|string $message[, int $newlines = 1 ]) : int|null
Parameters
$message : array<string|int, string>|string

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

Return values
int|null

The number of bytes returned from writing to stdout.

warn()

Convenience method for err() that wraps message between <warning /> tag

public warn([array<string|int, string>|string $message = '' ][, int $newlines = 1 ]) : int|null
Parameters
$message : array<string|int, string>|string = ''

A string or an array of strings to output

$newlines : int = 1

Number of newlines to append

Tags
see
https://book.cakephp.org/4/en/console-commands/input-output.html#creating-output
Return values
int|null

The number of bytes returned from writing to stderr.


        
On this page

Search results