Response::file PHP Method

file() public static method

Return the raw contents of a binary file.
public static file ( SplFileInfo | string $file, array $headers = [] ) : BinaryFileResponse
$file SplFileInfo | string
$headers array
return Symfony\Component\HttpFoundation\BinaryFileResponse
        public static function file($file, $headers = array())
        {
            return \Illuminate\Routing\ResponseFactory::file($file, $headers);
        }

Usage Example

Example #1
0
 public function testFile()
 {
     $file = new PhpStream('tests/data/response', 'wb');
     $file->write('foobar');
     $file->close();
     $response = Response::file('tests/data/response', 'text/plain');
     $this->assertEquals(Status::OK, $response->getStatusCode());
     $this->assertEquals('text/plain', $response->getHeaderLine('Content-Type'));
     $this->assertEquals('foobar', $response->getBody());
 }