fabpot/Silex — pull request #229 by igorw (2011-12-31 17:23:04+00:00)
Title: [stream] Add a nice API for streaming responses

This PR adds a nice API for creating streaming responses with the new StreamedResponse class that was added to symfony [just recently](https://github.com/symfony/symfony/pull/2935).

Usage is documented in the usage doc, but for lazy people:

```php
get('/images/{file}', function ($file) use ($app) {
if (!file_exists(__DIR__.'/images/'.$file)) {
return $app->abort(404, 'The image was not found.');
}

$stream = function () use ($file) {
readfile($file);
};

return $app->stream($stream, 200, array('Content-Type' => 'image/png'));
});
```

Note: I had to point the autoloader to a copy of symfony/symfony because the subtree splits are not up-to-date. Thus the vendors are out of date too right now.