Controller/FormController.php
public function submissions(SerializerInterface $serializer, Request $request): Response
    {
        /** @var int $id FormRead Id. */
        $id = (int) $request->get('id');

        $submissions = $this->formService->getFormSubmissions($id);

        $submissionsCsv = $serializer->encode($submissions, 'csv');

        $response = new Response($submissionsCsv);

        $response->headers->set('Content-Type', 'text/csv');
        $response->headers->set('Content-Disposition', 'attachment; filename="submissions.csv"');

        return $response;
    }
public function submissions(SerializerInterface $serializer, Request $request): Response
    {
        /** @var int $id FormRead Id. */
        $id = (int) $request->get('id');

        $submissions = $this->formService->getFormSubmissions($id);

        $submissionsCsv = $serializer->encode($submissions, 'csv');

        $response = new Response($submissionsCsv);

        $response->headers->set('Content-Type', 'text/csv');
        $response->headers->set('Content-Disposition', 'attachment; filename="submissions.csv"');

        return $response;
    }
@Route("/submissions", name="forms_submissions")

@param SerializerInterface $serializer
@param Request             $request

@return Response