CSV file not download

hello I try to download csv but it not working

$results = $this->getDoctrine()->getManager()->getRepository(‘AppBundle:Platform’)->findAll();

    $response = new StreamedResponse();
        function () use ($results) {
            $handle = fopen('php://output', 'w+');
            foreach ($results as $row) {
                //array list fields you need to export
                $data = array(
                fputcsv($handle, $data, ';', '"');
    $response->headers->set('Content-Encoding', 'UTF-8');
    $response->headers->set('Content-Type', 'text/csv');
    $response->headers->set('Content-Disposition', 'attachment; filename="platformes.csv"');

    return $response;

do nothing

fputcsv($handle, $data, ';', '"');

delete this line download with blank csv

please help

Source: Symfony Questions

Was this helpful?

0 / 0

Leave a Reply 0

Your email address will not be published. Required fields are marked *