duanlinjian5819 2014-11-25 08:55
浏览 236

Laravel错误与404页面

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

as a result im getting this error:

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

3条回答 默认 最新

  • dongyu5482 2014-11-25 09:37
    关注

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

    It should looks like that :

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

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

    Hope it helps.

    评论

报告相同问题?

悬赏问题

  • ¥15 DIFY API Endpoint 问题。
  • ¥20 sub地址DHCP问题
  • ¥15 delta降尺度计算的一些细节,有偿
  • ¥15 Arduino红外遥控代码有问题
  • ¥15 数值计算离散正交多项式
  • ¥30 数值计算均差系数编程
  • ¥15 redis-full-check比较 两个集群的数据出错
  • ¥15 Matlab编程问题
  • ¥15 训练的多模态特征融合模型准确度很低怎么办
  • ¥15 kylin启动报错log4j类冲突