title: Not able to download csv file in php laravel
body: <p>This is my controller action to download the backup of file in csv format. However  I am not able to download the file. I am  not able to understand what I am doing it wrong.</p>
  
  <pre><code>public function backup()
  {
  
  $dummy_data = array([
          'Name' =&gt; 'ABC',
          'Age'  =&gt; '26',
          'Sex'  =&gt; 'Male',
      ],
      [
          'Name' =&gt; 'C S',
          'Age'  =&gt; '33',
          'Sex'  =&gt; 'Male',
      ],
      [
          'Name' =&gt; 'Rose',
          'Age'  =&gt; '26',
          'Sex'  =&gt; 'Male',
      ],
      [
          'Name' =&gt; 'Der',
          'Age'  =&gt; '24',
          'Sex'  =&gt; 'Male',
      ]
  );
  
  $csv =  CSV::fromArray($dummy_data)-&gt;render();
  
  return $csv
  </code></pre>
  
  <p>}</p>
  
  <p>I am using this plugin to create csv file.</p>
  
  <p><a href="https://github.com/mnshankar/csv" rel="nofollow">https://github.com/mnshankar/csv</a></p>
  
  <p>Update:</p>
  
  <pre><code>echo $csv;  // Gives following output
  
  
  HTTP/1.0 200 OK
  Cache-Control:       private
  Content-Disposition: attachment; filename="export.csv"
  Content-Type:        text/csv
  Date:                Wed, 14 Jan 2015 12:29:04 GMT
  Pragma:              cache
  
  Name,Age,Sex
  ABC,26,Male
  "C S",33,Male
  Rose,26,Male
  Der,24,Male
  </code></pre>