Skip to content
master
Go to file
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

File Response

Build Status

This package wraps the Response object of the Symfony HttpFoundation component for file output. The concrete classes allow you to avoid the boilerplate involved in setting up a file download response.

Install

Via Composer

{
    "require": {
        "conorsmith/fileresponse": "0.3.*"
    }
}

Available File Types

  • CsvFileResponse (text/csv)
  • GifFileResponse (image/gif)
  • JpegFileResponse (image/jpeg)
  • PdfFileResponse (application/pdf)
  • PngFileResponse (image/png)
  • TextFileResponse (text/plain)
  • ZipFileResponse (application/zip)

Examples

use ConorSmith\FileResponse\TextFileResponse;

$response = new TextFileResponse('example.txt', 'This is the text file\'s contents');
$response->send();

You can use the abstract FileResponse class to create your own custom file responses.

use ConorSmith\FileResponse\FileResponse;

class NsfwJpegFileResponse extends FileResponse
{
    public function __construct($filename, $content)
    {
        parent::__construct($filename, $content, array(
            'Content-Type' => 'image/jpeg',
            'X-Content-NSFW' => true,
        ));
    }
}

About

Wrapper for responses in the Symfony HttpFoundation component.

Resources

License

Languages

You can’t perform that action at this time.