PSR standards · Question 5 of 12

Which method must a class implement to fulfil the PSR-15 MiddlewareInterface?

1 answer is correct. Easy

Show answer

Answer

  • B process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface

Explanation

The MiddlewareInterface requires exactly one method: process(), which receives the request and the next handler and returns a response. handle() belongs to the second PSR-15 interface, the RequestHandlerInterface, i.e. the object the middleware passes the request on to. The variant with __invoke() taking request and response comes from older so-called double-pass middlewares, which PSR-15 deliberately did not adopt. dispatch(), in contrast, is the method of the PSR-14 event dispatcher and has nothing to do with middlewares.

Certifications & exams

Which exam comes next?

You can already practise for 19 exams, and 21 are up for a vote. See all certifications with their official information, cast your vote or suggest your exam.

See all certifications