Group Middleware error

Using the Group Middleware example from throws this error:

Fatal error : Uncaught TypeError: Return value of Slim\Handlers\Strategies\RequestResponse::__invoke() must implement interface Psr\Http\Message\ResponseInterface, int returned

What is the fix to this error?

Only this code could cause the error you mentioned:

return $response->getBody()->write('data');


I didn’t find it in the documentation. Where exactly did you find it?

I found it here.

$app->get('/', function (Request $request, Response $response) {
    return $response->getBody()->write('Hello World');

Replace it with this code:

$app->get('/', function (Request $request, Response $response) {
    $response->getBody()->write('Hello World');
    return $response;

This page will be fixed soon:

Thanks for the fix Odan.