To simplify the usage of Expressive, we added the run() method, which handles the incoming request, and emits a response.

The latter aspect, emitting the response, is the responsibility of an emitter. An emitter accepts a response instance, and then does something with it, usually sending the response back to a browser.

Diactoros defines an EmitterInterface, and — as of the time we write this — a single emitter implementation, Zend\Diactoros\Response\SapiEmitter, which sends headers and output using PHP's standard SAPI mechanisms (the header() method and the output buffer).

We recognize that there are times when you may want to use alternate emitter implementations; for example, if you use React, the SAPI emitter will likely not work for you.

To facilitate alternate emitters, we offer two facilities:


The EmitterStack is an SplStack extension that implements EmitterInterface. You can add emitters to the stack by pushing them on:


As a stack, execution is in LIFO (last in, first out) order; the first emitter on the stack will be evaluated last.

Deprecated with version 2.2

Starting in version 2.2, the EmitterStack is deprecated, and moved, along with the zend-diactoros EmitterInterface and implementations, to a new package, zend-httphandlerrunner.

The interface and the EmitterStack are roughly identical to what is present in version 2; if you are defining a Zend\Diactoros\Emitter\EmitterInterface service of your own, you will need to update it in that version.