I'm facing a problem while implementing micro application in which I want a middle ware that is executed after response is send to browser. As mentioned in documentation of Phalcon finish middle ware suppose to that work but its not working, browser still waiting to complete whole process then it return response.
my code is like:
$app->before(function() use ($app, $di) {
$di->get('log')->log("This is a message before");
$di->get('log')->close();
});
$testCtrl = new testCtrl();
$app->get('/ctrltest', array($testCtrl, "indexAction"));
$app->after(function() use ($app, $di) {
echo "after";
$di->get('log')->log("This is a message after");
$di->get('log')->close();
});
$app->finish(function() use ($app, $di) {
$count = 100000;
while ($count) {
$di->get('log')->log("count " . $count);
$count--;
}
});
Response are coming after whole loop is executed. Any sample code or some suggestion will be helpful