Php Slim framework 404错误页面显示未找到错误
我正在更改slim framework v2上的默认404错误页面 这是我正在使用的代码:Php Slim framework 404错误页面显示未找到错误,php,slim,Php,Slim,我正在更改slim framework 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文件放在与index.php相同的文件夹中,其
$app->notFound(function () use ($app) {
$app->render('404.html');
});
但是,我遇到了以下错误:
Message: View cannot render `404.html` because the template does not exist
我将404.html文件放在与index.php相同的文件夹中,其中包含Slim代码。另外,为了检查,我还复制了slim文件夹中的404.html文件。不过,我还是犯了同样的错误。是否有与模板相关的内容?[已解决]
我使用以下代码解决了此问题:
$app->notFound(function () use ($app) {
$app->view->setTemplatesDirectory("Slim/");
$app->render('404.html');
});
我只需要设置模板目录