簡體   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