title: symfony export html.twig to csv
body: <p>i'm trying to export a twig view into csv, but i'm stuck, can someone help me out with detailled solution ?
  peace</p>
  
  <pre><code>/**
   *  
   * @Route("/export", name="export_csv")
   */
  public function exportAction() {
  
      $entity = new Invite();
      $form = $this-&gt;createForm(new ManifSearchType(), $entity);
      $request = $this-&gt;get('request');
  
      $em = $this-&gt;getDoctrine()-&gt;getManager();
  
      $view = $this-&gt;render('PrifProtocoleBundle:Invite:index.html.twig', array(
          'form' =&gt; $form-&gt;createView()));
  
      $handle = fopen('php://memory', 'r+');
      $header = array();
  
      fputcsv($handle, $view);
  
      rewind($handle);
  
      $content = stream_get_contents($handle);
      fclose($handle);
  
      return new Response($content, 200, array(
          'Content-Type' =&gt; 'application/force-download',
          'Content-Disposition' =&gt; 'attachment; filename="export.csv"'
      ));
  } 
  </code></pre>
  
  <p>error message:</p>
  
  <pre><code>Warning: fputcsv() expects parameter 2 to be array, object given in C:\wamp\www\protocole\src\Prif\ProtocoleBundle\Controller\InviteController.php line 56 
  </code></pre>