$app->get('/download-pdf', function() use($app) { $pdf_path = '/path/to/pdf/file.pdf'; return $app->sendFile($pdf_path, 200, array('Content-Type' => 'application/pdf')); });
$app->get('/download-csv', function() use($app) { $csv_path = '/path/to/csv/file.csv'; return $app->sendFile($csv_path, 200, array('Content-Type' => 'text/csv')); });In the above example, the sendFile method is used to download a CSV file. The method takes the CSV file path as an argument and sends it to the client with the Content-Type as text/csv. Package Library: The Silex micro-framework has a built-in sendFile method which is available as part of the Symfony HttpFoundation component. Therefore, the package library is Symfony HttpFoundation.