PHPackages                             vcn/symfony-writer - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vcn/symfony-writer

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vcn/symfony-writer
==================

Stream writing library that supports listening in on the stream

v1.0.1(6y ago)026MITPHPPHP &gt;=7.1

Since Jan 25Pushed 6y ago2 watchersCompare

[ Source](https://github.com/vcn/symfony-writer)[ Packagist](https://packagist.org/packages/vcn/symfony-writer)[ RSS](/packages/vcn-symfony-writer/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (4)Used By (0)

vcn/symfony-writer
==================

[](#vcnsymfony-writer)

vcn/symfony-writer is a library that provides an alternative to the StreamedResponse-class of Symfony. In contrast to StreamedResponse, WriterResponse allows you to attach listeners and capture what is being responded.

Installation
------------

[](#installation)

Install using composer in your symfony-project:

```
composer require vcn/symfony-writer
```

Usage
-----

[](#usage)

Usage is similar to usage of the StreamedResponse, with a few small changes:

- the callback now takes an instance of `\Vcn\Symfony\HttpFoundation\Writer` as first and only argument
- instead of echo-ing, you should call `Writer::write` with the data to output as string parameter
- before the response is sent, you can attach a listener to the response using `Writer::attachListener`

Example:

```
