conorsmith / fileresponse
This package is abandoned and no longer maintained.
No replacement package was suggested.
Wrapper for responses in the Symfony HttpFoundation component.
v0.3.1
2014-09-06 13:13 UTC
Requires
- symfony/http-foundation: 2.6.*@dev
Requires (Dev)
- phpunit/phpunit: ~4.0
This package is not auto-updated.
Last update: 2021-09-06 07:57:18 UTC
README
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,
));
}
}