I'm trying to download the current html page as a file in symfony :
My twig :
<a href="{{ path('polytech_skills_evaluations_export', {'idssoccasion': ssoccasion.id, 'idevalue':user.id}) }}" >Exporter </a>
My Controller
$html= $this->renderView('PolytechSkillsBundle:Evaluation/Evaluation:type2.html.twig', array(
'form' => $form->createView(),
'niveaux' => $niveaux,
'date' => $dateCourante,
'evalue' => $evalue,
'ssoccasion' => $ssoccasion,
'lasteval' => $lastEval,
'lastevalforocc' => $lastEvalForOccasion,
'objectifs' => $objectifs
));
$response = new Response();
// Set headers
$response->headers->set('Cache-Control', 'private');
$response->headers->set('Content-type', mime_content_type($html));
$response->headers->set('Content-Disposition', 'attachment; filename="' . basename($html) . '";');
$response->headers->set('Content-length', filesize($html));
// Send headers before outputting anything
$response->sendHeaders();
$response->setContent(file_get_contents($html));
The error I get :
Warning: mime_content_type failed to open stream: Invalid argument
500 Internal Server Error - ContextErrorException