Equivalent of file_transfer()? I am porting a Drupal 7 module to Drupal 8; it has a call to file_transfer($uri, $headers). What's the equivalent Drupal 8 code for this?
It seems file_transfer was removed in favor of BinaryFileResponse.


  Symfony has a Symfony\Component\HttpFoundation\BinaryFileResponse
  class that can be used to deliver files through PHP to the client. It
  also supports X-Sendfile and X-Accel-Mapping via
  BinaryFileResponse::trustXSendfileTypeHeader().
  
  file_transfer() has been dropped in favor of that.
  
  Drupal 7:

&lt;?php return file_transfer($uri, $headers); ?&gt;

  
  Drupal 8:

&lt;?php 
use Symfony\Component\HttpFoundation\BinaryFileResponse; ...
return new BinaryFileResponse($uri, 200, $headers); 
?&gt;



When looking for exact replacements and changes in D8, check the relevant api.drupal.org doc page and change records. I find it really comprehensive and has almost every change. 

On a side note, I would reevaluate the module code if it happens for you to file_trasnfer() a file. Entire menu system was replaced with Symfony components and I think the odds are, you are still using the old system if it happens to file_transfer() or use some request-response thing in the site.