Skip to content

Commit

Permalink
Fix example in README
Browse files Browse the repository at this point in the history
  • Loading branch information
mnapoli committed Dec 2, 2017
1 parent 3ab1a15 commit fc7dada
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ require 'vendor/autoload.php';
$app = new Slim\App();

$app->get('/hello/{name}', function ($request, $response, $args) {
return $response->write("Hello, " . $args['name']);
return $response->getBody()->write("Hello, " . $args['name']);
});

$app->run();
Expand Down

1 comment on commit fc7dada

@rotexdegba
Copy link

@rotexdegba rotexdegba commented on fc7dada Jan 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$response->getBody()->write("Hello, " . $args['name']); will return an int.

$response->getBody() returns an instance of \Psr\Http\Message\StreamInterface.

See definition of \Psr\Http\Message\StreamInterface::write($string).

Example should be changed to:

$app->get('/hello/{name}', function ($request, $response, $args) {

    $response->getBody()->write("Hello, " . $args['name']);

    return $response;
 });

Please sign in to comment.