我在实现微应用程序时遇到问题,我希望在响应发送到浏览器后执行中间件。正如phalcon 完成中间件的文档中所提到的,假设该工作不起作用,浏览器仍在等待完成整个过程然后它返回响应。
我的代码就像:
$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) {`enter code here`
$di->get('log')->log("count " . $count);
$count--;
}
});
响应在整个循环执行后发生。任何示例代码或一些建议都会有所帮助