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"}
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"}
// notAllowedHandler
$container['notAllowedHandler'] = function ()
{
return function ($req, $res, $allowMethod) {
return $res->withJson([
"status" => 0,
"info" => "",
"data" => $allowMethod
]);
};
};
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 caus...
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! ...