Laravel 404页面错误 [英] Laravel error with 404 page

查看:109
本文介绍了Laravel 404页面错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

im trying to implement code of 404 page in my website. Im using this code in my filters.php but i also tried to use in 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

i do it an aother way. What is going to happen when 404 is raised is normally declared in app/start/global.php

应该看起来像这样:

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);

This just called the app/views/errors/404.blade.php anytime laravel raised a 404 or if you decide to manually call App::abort(404);

希望有帮助.

这篇关于Laravel 404页面错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆