Symfony\Component\HttpFoundation\BinaryFileResponse::create PHP Method

create() public static method

public static create ( SplFileInfo | string $file = null, integer $status = 200, array $headers = [], boolean $public = true, null | string $contentDisposition = null, boolean $autoEtag = false, boolean $autoLastModified = true ) : BinaryFileResponse
$file SplFileInfo | string The file to stream
$status integer The response status code
$headers array An array of response headers
$public boolean Files are public by default
$contentDisposition null | string The type of Content-Disposition to set automatically with the filename
$autoEtag boolean Whether the ETag header should be automatically set
$autoLastModified boolean Whether the Last-Modified header should be automatically set
return BinaryFileResponse The created response
    public static function create($file = null, $status = 200, $headers = array(), $public = true, $contentDisposition = null, $autoEtag = false, $autoLastModified = true)
    {
        return new static($file, $status, $headers, $public, $contentDisposition, $autoEtag, $autoLastModified);
    }

Usage Example

 public function testXSendfile()
 {
     $request = Request::create('/');
     $request->headers->set('X-Sendfile-Type', 'X-Sendfile');
     BinaryFileResponse::trustXSendfileTypeHeader();
     $response = BinaryFileResponse::create('README.md');
     $response->prepare($request);
     $this->expectOutputString('');
     $response->sendContent();
     $this->assertContains('README.md', $response->headers->get('X-Sendfile'));
 }
All Usage Examples Of Symfony\Component\HttpFoundation\BinaryFileResponse::create