[英]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.