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
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());
 }