Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Niklas Fiekas on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
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:
return file_transfer($uri, $headers);
Drupal 8:
use Symfony\Component\HttpFoundation\BinaryFileResponse;
...
return new BinaryFileResponse($uri, 200, $headers);
Ref: http://symfony.com/doc/current/components/http_foundation/introduction.h...
Impacts:
Module developers