I am trying to create a csv and download it to the browser. There is almost ZERO documentation on this in Symfony2 from what I can find.
Here is my code:
// Pass in all of the variables that will make up the pdf...
$response = $this->renderView('WICPurchaseOrderBundle:PurchaseOrder:csv.html.twig', array( "data"=>$data
)
);
$response->headers->set('Content-Type', 'text/csv'); // This is line 929 in the error.
$response->headers->set('Content-Disposition', 'attachment; filename="teams.csv"');
return $response;
This is the error I get:
Notice: Trying to get property of non-object in /Applications/XAMPP/xamppfiles/htdocs/symfonydev/src/WIC/PurchaseOrderBundle/Controller/PurchaseOrderController.php line 929
Anyone have an experience with CSV's in Symfony2 and can help me out? Thanks!