title: Return an xml file avoiding to echo it
body: <p>I know one should not use <code>echo</code> in controllers, but I don't understand what I should use to return an xml in order to download it. Please note, <em>it's not a file on the server</em>, it's just a string:</p>
  
  <pre><code>public function export()
  {
      $this-&gt;autoRender = false;
  
      $id = $this-&gt;request-&gt;getQuery('id');
      $invoice = $this-&gt;Invoices-&gt;get($id, ['contain' =&gt; ['Customers', 'ItemInvoices' =&gt; ['ItemProformas' =&gt; ['ItemDeliveryNotes' =&gt; ['ItemOrders' =&gt; ['Orders' =&gt; ['Customers']]]]]]]);
  
      $fpr = new ExportInvoice();
      $fpr-&gt;SetInvoice($invoice);
  
      header('Content-type: text/xml');
      header('Content-Disposition: attachment; filename="' . $fpr-&gt;getFilename() . '"');
  
      $xml = $fpr-&gt;asXML();
      echo $xml;
  }
  </code></pre>
  
  <p>it actually works as expected: the browser download a file with the given filename and its content is the <code>$xml</code> value.</p>
  
  <p>But at the end of the file there are warnings about headers:</p>
  
  <pre><code>Warning (512): Unable to emit headers. Headers sent in file=/home/mark/myproject/src/Controller/InvoicesController.php line=130 [CORE/src/Http/ResponseEmitter.php, line 51]
  Warning (2): Cannot modify header information - headers already sent by (output started at /home/mark/myproject/src/Controller/InvoicesController.php:130) [CORE/src/Http/ResponseEmitter.php, line 152]
  Warning (2): Cannot modify header information - headers already sent by (output started at /home/mark/myproject/src/Controller/InvoicesController.php:130) [CORE/src/Http/ResponseEmitter.php, line 181]
  Warning (2): Cannot modify header information - headers already sent by (output started at /home/mark/myproject/src/Controller/InvoicesController.php:130) [CORE/src/Http/ResponseEmitter.php, line 181]
  </code></pre>
  
  <p>As far as I know this is due to the usage of <code>echo</code> in controller. It may happens there's an output before sending the header, and then the warnings.</p>
  
  <p>What's the correct way to replace the <code>echo</code> function?</p>