Problems about the introduction of Request and Response in the use of slim

when using php"s lightweight slim framework, I found two introduction of Request and Response:
1. Slim\ Http\ Request;
2. \ Psr\ Http\ Message\ ServerRequestInterface
I wonder if there is a difference between the two?
if mixed, will it cause an error?

Jul.06,2021

using 1
2 is interface Ah


ServerRequestInterface is a Request interface based on PSR-7 specification

Request is an implementation of ServerRequestInterface

ServerRequestInterface should be injected when using dependency injection
only Request can be used in practical use

  • Error in how the slim framework customizes the request method

    for example, the POST request interface is specified, but a request from GET will report an error as shown in the following figure so how do you customize the returned errors? For example, { "error ": "Method not allowed "} is returned. ...

    Mar.01,2021
  • Who has used the slim,URL parameter?

    the following code: require vendor autoload.php ; $app->get( hello[ {name}] , function ($request, $response, $args) { $response->write("Hello, " . $args[ name ]); return $response; })->setArgument( name , World! ...

    Jul.22,2021
Menu