Skip to content

Commit

Permalink
Merge pull request #671 from odan/v4.11
Browse files Browse the repository at this point in the history
Update Routing - Writing content to the response
  • Loading branch information
akrabat committed Jul 7, 2023
2 parents 4ee5438 + 67bc39d commit f8168b0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion docs/v4/objects/routing.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit f8168b0

Please sign in to comment.