/** * @param string $zipPath * @param Application $app * @param string $filename * @return \Symfony\Component\HttpFoundation\StreamedResponse */ private function outputBundle($zipPath, Application $app, $filename) { $stream = function () use($zipPath) { echo file_get_contents($zipPath); unlink($zipPath); }; $response = $app->stream($stream, Response::HTTP_OK, array('Content-length' => filesize($zipPath), 'Content-Type' => 'application/zip', 'Pragma' => 'no-cache', 'Cache-Control' => 'no-cache')); $response->headers->set('Content-Disposition', $response->headers->makeDisposition(ResponseHeaderBag::DISPOSITION_ATTACHMENT, 'phansible_' . $filename . '.zip')); return $response; }