| Methods |
public
|
set(Closure($this): void $fx = null, bool|string $event = null)
Set a callback method which will be executed with the output sent back to the terminal.
Set a callback method which will be executed with the output sent back to the terminal.
Argument passed to your callback will be $this Console. You may perform calls
to methods such as
$console->output()
$console->outputHtml()
If you are using setModel, and if your model implements \Atk4\Core\DebugTrait,
then you you will see debug information generated by $this->debug() or $this->log().
This intercepts default application logging for the duration of the process.
If you are using runCommand, then server command will be executed with it's output
(stdout and stderr) redirected to the console.
While inside a callback you may execute runCommand or setModel multiple times.
Parameters
| $fx |
callback which will be executed while displaying output inside console
|
| $event |
"true" would mean to execute on page load, string would indicate
JS event. See first argument for View::js()
|
Overrides
|
#
|
public
|
jsExecute(): JsBlock
|
#
|
private
|
escapeOutputHtml(string $message): string
|
#
|
public
|
output(string $message, array $context = []): $this
Output a single line to the console.
Output a single line to the console.
|
#
|
public
|
outputHtml(string $messageHtml, array $context = []): $this
Output unescaped HTML to the console.
Output unescaped HTML to the console.
|
#
|
protected
|
outputHtmlWithoutPre(string $messageHtml, array $context = []): $this
Output unescaped HTML to the console without wrapping in <pre>.
Output unescaped HTML to the console without wrapping in .
|
#
|
protected
|
renderView(): void
View-specific rendering stuff. Feel free to replace this method with
your own. View::renderView contains some logic…
View-specific rendering stuff. Feel free to replace this method with
your own. View::renderView contains some logic that integrates with
Fomantic-UI.
Overrides
|
#
|
public
|
send(JsExpressionable $js): $this
Executes a JavaScript action.
Executes a JavaScript action.
|
#
|
public
|
exec(string $command, array $args = []): ?bool
Executes command passing along escaped arguments.
Executes command passing along escaped arguments.
Will also stream stdout / stderr as the command executes.
once command terminates method will return the exit code.
This method can be executed from inside callback or
without it.
Example: $console->exec('ping', ['-c', '5', '8.8.8.8']);
All arguments are escaped.
|
#
|
protected
|
execRaw(string $command, array $args = []): array{resource, non-empty-array}
|
#
|
public
|
runMethod(object|class-string $object, string $method, array $args = []): $this
Execute method of a certain object. If object uses Atk4\Core\DebugTrait,
then debugging will also be used.
Execute method of a certain object. If object uses Atk4\Core\DebugTrait,
then debugging will also be used.
During the invocation, Console will substitute $app->logger with itself,
capturing all debug/info/log messages generated by your code and displaying
it inside console.
// runs $userController->generateReport('pdf')
Console::addTo($app)->runMethod($userController, 'generateReports', ['pdf']);
// runs PainFactory::lastStaticMethod()
Console::addTo($app)->runMethod('PainFactory', 'lastStaticMethod');
To produce output:
- use $this->debug() or $this->info() (see documentation on DebugTrait)
NOTE: debug() method will only output if you set debug=true. That is done
for the $userController automatically, but for any nested objects you would have
to pass on the property.
|
#
|
public
|
emergency($message, array $context = []): void
|
#
|
public
|
alert($message, array $context = []): void
|
#
|
public
|
critical($message, array $context = []): void
|
#
|
public
|
error($message, array $context = []): void
|
#
|
public
|
warning($message, array $context = []): void
|
#
|
public
|
notice($message, array $context = []): void
|
#
|
public
|
info($message, array $context = []): void
|
#
|
public
|
debug($message, array $context = []): void
|
#
|
public
|
log(LogLevel::* $level, $message, array $context = []): void
|
#
|