From 67bc39d92caffa31c9c3a314870f2ac6bd1e11b1 Mon Sep 17 00:00:00 2001 From: Daniel Opitz Date: Fri, 7 Jul 2023 11:12:27 +0200 Subject: [PATCH] Update Routing - Writing content to the response --- docs/v4/objects/routing.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/docs/v4/objects/routing.md b/docs/v4/objects/routing.md index 7f8d7a79..23df7fe8 100644 --- a/docs/v4/objects/routing.md +++ b/docs/v4/objects/routing.md @@ -138,7 +138,15 @@ Each routing method described above accepts a callback routine as its final argu ### Writing content to the response -There are two ways you can write content to the HTTP response. First, you can simply `echo()` content from the route callback. This content will be appended to the current HTTP response object. Second, you can return a `Psr\Http\Message\ResponseInterface` object. +There are two ways to write content to the HTTP response: + +1. Using the `$response->getBody()->write('my content');` method of the Response object. + +2. Simply `echo()` content from the route callback. +This content will be appended or prepended to the current HTTP response object +if you add the [Output Buffering Middleware](/docs/v4/middleware/output-buffering.html). + +Please note that since Slim 4, you must return a `Psr\Http\Message\ResponseInterface` object. ### Closure binding