我正在尝试文档中的这个示例:Streaming a Response in Symfony2。
/**
* @param Request $request
* @return Response $render
* @Route("/streamedResponse", name="streamed_response")
* @Template("AcmeTestBundle::streamedResponse.html.twig")
*/
public function streamedResponseAction(Request $request)
{
$response = new StreamedResponse();
$response->setCallback(function () {
echo 'Hello World';
flush();
sleep(3);
echo 'Hello World';
flush();
});
return $response;
}
这会同时输出所有内容。我做错了什么吗?