This may be a daft question but I have been seeing and reading HTTP messages or PSR-7 in the current trend on PHP for development. Why out of a sudden we need HTTP message implementations in PHP for the modern web development?
For instance, with Slim 3, now we are to do this,
$app->get('/hello/{name}', function ($request, $response, $args) {
$response->write("Hello, " . $args['name']);
return $response;
});
We now must 'wrap' the request's result in the HTTP response object.
What is wrong with this old classic way of responding the request below?
echo 'Hello, ' . $_GET('name');
It is easier to understand for me.
What are the benefits of implementing HTTP messages? When do we need to use them? And why?