class atk4\\ui\Console



With console you can output real-time information about the process. We have put a lot of time to capture the output that may be generated by various means and stream it in real-time into HTML component.

Console uses Server Sent Event (jsSSE) which works pretty much out-of-the-box with the modern browsers and unlike websockets do not require you to set up additional ports on the server.


Basic Usage


After adding a console to your Render Tree, you just need to set a call-back:

$console = $app->add('Console');
$console->set(function($console) {

    // This will be executed through SSE request


    echo 'world'; // also will be redirected to console


    $console->send(new \atk4\ui\jsExpression('alert([])', ['The wait is over']);

Console integrates nicely with DebugTrait (, and also allows you to execute shell process on the server while redirecting output in real-time.

Using With Model

We recommend that you pack up your busineess logic into your Model methods. When it’s time to call your method, you could either do this:


Which would execute your own routine for some report generation, but doing it though a normal request will look like your site is slow and is unable to load page quick. Alternative is to run it through a console:

$console->setModel($user, 'generateReport', [30]);

This will display console to the user and will even output information from inside the model:

$this->info('converting report to PDF');