[英]Slim framework 404 error page showing not found error
我正在更改我的超薄框架 v2 上的默認 404 錯誤頁面。
這是我正在使用的代碼:
$app->notFound(function () use ($app) {
$app->render('404.html');
});
但是,我收到此錯誤:
Message: View cannot render `404.html` because the template does not exist
我的 404.html 文件與包含 Slim 代碼的 index.php 位於同一文件夾中。 另外,為了檢查一下,我也將 404.html 文件復制到了我的 slim 文件夾中。 盡管如此,我還是遇到了同樣的錯誤。 有沒有與模板有關的東西?
[解決了]
我使用以下代碼解決了這個問題:
$app->notFound(function () use ($app) {
$app->view->setTemplatesDirectory("Slim/");
$app->render('404.html');
});
我只需要設置模板目錄。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.