I don't see how to use this library and actually return a csv file, I'd like it to open automatically, if I use headers it returns an empty file
use Symfony\Component\Serializer\Serializer;
use Symfony\Component\Serializer\Encoder\CsvEncoder;
use Symfony\Component\Serializer\Normalizer\ObjectNormalizer;
class export {
public function index($data) {
header('Content-type: text/csv');
$serializer = new Serializer([new ObjectNormalizer()], [new
CsvEncoder()]);
// instantiation, when using it inside the Symfony framework
$serializer = $container->get('serializer');
// encoding contents in CSV format
return $serializer->encode($data, 'csv');
}
}