Thin 2 wash buffer

I am writing an application with Slim2 Framework, but I have one problem, I do not know how to solve it.

I wrote a personal class that develops some data, and it takes 5 minutes to complete.

class MyClass
{
  function a(){
  //some code
    for ($i = 0; $i < $n; $i++) {
      //start cycle 
      //some code
      flush();
      ob_flush();
    }
    return $array //an array with some data
  }
 }

This function runs in my application in Slim2

$app->get('/myapp/', function () use ($app, $i ){
 $app->myclass->a()

   $app->render('mypage.twig', array(
     'someVariables' => $app->myclass->someVariables,
   ));
})->name('myapp');

and someVariables is controlled in the branch template.

The problem is that I cannot do a partial result, as I can do with flush () and ob_flush (). I would like to get the result, at least at the end of each cycle, instead I get the full result when the function ends.

I tried with {% flush%} in the branch template, but I have the same problem.

Is it possible to manipulate the output buffering in slim2 so that I can print a piece of the page, rather than wait for the whole page to be built?

+4

Source: https://habr.com/ru/post/1625305/


All Articles