10
我們已經知道如何在斯利姆3添加自定義404 notFoundHandler
:如何在Slim 3中手動啓動404處理程序?
$container['notFoundHandler'] = function ($c) {
return function ($request, $response) use ($c) {
return $c->view->render($response, 'pages/404.html.twig')
->withStatus(404)
->withHeader('Content-Type', 'text/html');
};
};
我想在我的路線之一,手動觸發此。
在Slim 2中,我們能夠做些類似於$app->notFound()
的事情。 Slim 3中的等價物是什麼?