我遵循以下教程:http://www.slimframework.com/docs/tutorial/first-app.html
它告诉我将以下代码添加到我的index.php文件中:
<?php
use \Psr\Http\Message\ServerRequestInterface as Request;
use \Psr\Http\Message\ResponseInterface as Response;
require '../vendor/autoload.php';
$app = new \Slim\App;
$app->get('/hello/{name}', function (Request $request, Response $response) {
$name = $request->getAttribute('name');
$response->getBody()->write("Hello, $name");
return $response;
});
$app->run();
但是,当我使用Postman对运行上述php程序的服务器进行API调用时,我收到以下响应: