Final Class Yiisoft\Yii\Http\Handler\NotFoundHandler
| Inheritance | Yiisoft\ |
|---|---|
| Implements | Psr\ |
NotFoundHandler is used as a fallback handler by default {@see Application}.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\ |
|
| handle() | Handles a request and produces a response. | Yiisoft\ |
Method Details
| public mixed __construct ( \ | ||
| $responseFactory | \ |
|
public function __construct(
private readonly ResponseFactoryInterface $responseFactory,
) {}
Handles a request and produces a response.
May call other collaborating code to generate the response.
| public \ | ||
| $request | \ |
|
public function handle(ServerRequestInterface $request): ResponseInterface
{
$path = $request->getUri()->getPath();
$response = $this->responseFactory->createResponse(Status::NOT_FOUND);
$response->getBody()->write("We were unable to find the page \"$path\".");
return $response;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.