On this page
The documentation you are viewing is for an older version of this component.
Switch to the latest (v3) version.
To simplify the usage of Mezzio, 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,
sends headers and output using PHP's standard SAPI mechanisms (the
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:
Applicationcomposes an emitter, and you can specify an alternate emitter during instantiation, or via the
Laminas\Diactoros\Response\EmitterInterfaceservice when using the container factory.
- Second, we provide
Mezzio\Emitter\EmitterStack, which allows you to compose multiple emitter strategies; the first to return a value other than boolean
falsewill cause execution of the stack to short-circuit.
EmitterStackby default, with an
SapiEmittercomposed at the bottom of the stack.
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.
Found a mistake or want to contribute to the documentation? Edit this page on GitHub!