繁体   English   中英

Laravel 404页面错误

[英]Laravel error with 404 page

我试图在我的网站上实现404页面的代码。 我在我的filters.php中使用此代码,但我也尝试在global.php中使用

App::missing(function($exception)
{
 return View::make('404');
}

结果即时通讯收到此错误:

Symfony \ Component \ Debug \ Exception \ FatalErrorException
Call to a member function getAction() on a non-object

我是另一种方式。 通常在app / start / global.php中声明提高404时会发生什么

它看起来应该像这样:

App::error(function($exception, $code)
{
    switch ($code)
    {
        case 403:
            return Response::view('errors.403', array(), 403);
        case 404:
            return Response::view('errors.404', array(), 404);
    }
}

当laravel提出404或您决定手动调用App :: abort(404)时,这仅称为app / views / errors / 404.blade.php。

希望能帮助到你。

我在Google上搜索了更多有关它以及我如何理解它的问题,这些问题来自nginx。 可能? 顺便说一句,它没有刀片模板工作,但我需要它。 所以需要找出解决方法

在布局或404页面的视图或编写器中看起来像。 你有类似的东西:

Route::getCurrentRoute()->getAction()

要么

Route::current()->getAction()

或到目前为止,我记得Route :: getCurrentRoute,当404为null时,它将说明您的错误...

我用来检查当前Route是否是Route by的实例:

$currentRoute = \Route::getCurrentRoute();
if ($currentRoute instanceof Route) {
    // Do What you want here
    $currentRoute->getAction()//...
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM