I am trying this example from the doc: 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;
}
This outputs everything at the same time. Have I done something wrong?