3 回答
TA贡献1886条经验 获得超2个赞
您的中间件没有实现 PSR-15。您不应该传递响应,而是传递请求处理程序接口:
namespace Psr\Http\Server;
use Psr\Http\Message\ResponseInterface;
use Psr\Http\Message\ServerRequestInterface;
/**
* Participant in processing a server request and response.
*
* An HTTP middleware component participates in processing an HTTP message:
* by acting on the request, generating the response, or forwarding the
* request to a subsequent middleware and possibly acting on its response.
*/
interface MiddlewareInterface
{
/**
* Process an incoming server request.
*
* Processes an incoming server request in order to produce a response.
* If unable to produce the response itself, it may delegate to the provided
* request handler to do so.
*/
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface;
}
https://www.php-fig.org/psr/psr-15/
TA贡献1810条经验 获得超4个赞
首先,您需要检查您使用的是哪个超薄版本,当我开始学习时,我也遇到了这个错误/问题,但您想解决这个问题,您可以在您的代码中进行此编辑。
$APP = AppFactory::create();
$app->setBasePath("/myapp/public/index.php");
$APP->add(function(Request $request, Response $response, callable $next){
$response = $next($request,$response);
return $response;
});
- 3 回答
- 0 关注
- 185 浏览
添加回答
举报
