Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/279.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php laravel-4:如何找到NotFoundHttpException的路由?_Php_Laravel 4 - Fatal编程技术网

Php laravel-4:如何找到NotFoundHttpException的路由?

Php laravel-4:如何找到NotFoundHttpException的路由?,php,laravel-4,Php,Laravel 4,我在日志中发现NotFoundHttpException。看起来是这样的: [2013-11-26 13:49:20] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1429 Stack trace: #0 /var

我在日志中发现NotFoundHttpException。看起来是这样的:

[2013-11-26 13:49:20] log.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' in /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1429
Stack trace:
#0 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1050): Illuminate\Routing\Router->handleRoutingException(Object(Symfony\Component\Routing\Exception\ResourceNotFoundException))
#1 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1014): Illuminate\Routing\Router->findRoute(Object(Illuminate\Http\Request))
#2 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(530): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#3 /var/www/myproject/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(506): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#4 /var/www/myproject/public/index.php(49): Illuminate\Foundation\Application->run()
#5 {main} [] []
这不会告诉您什么,只是浪费磁盘空间


如何找到导致NotFoundHttpException的URI?

app/start/global.php
extend
app::error()
中:

现在,您将获得一个带有URL的附加日志条目:

 [2013-11-26 14:20:07] log.ERROR: NotFoundHttpException Route: http://myproject.net/asdfgsdfghsdfg [] []
您可以从日志文件中筛选404(NotFoundHttpException)错误。
文件位置:app/start/global.php

App::error(function(Exception $exception, $errorCode)
{
    $requestUrl = Request::fullUrl(); 
    $userAgent = Request::header('user-agent');

    if($errorCode != 404){
        Log::error('Exception', array(
            'errorCode' => $errorCode,
            'requestUrl' => $requestUrl,
            'userAgent' => $userAgent,
            'context' => $exception,
        ));     
    }

    return Response::view('error-page-path.error-404', array(), 404);
    // Here "error-404" is a blade view file in "error-page-path" directory
});

可能重复:请查看。它告诉你如何找出哪里出了问题,哪里出了问题。很好的发现。你能解释一下为什么它需要命名吗?@NikosGr基本上是因为这是对象的名称。如果您查看
get\u name($exception)
它有这个名称空间,并且
instanceof
将与这个名称进行比较。@PiTheNumber,您救了我!!这让我发疯。
App::error(function(Exception $exception, $errorCode)
{
    $requestUrl = Request::fullUrl(); 
    $userAgent = Request::header('user-agent');

    if($errorCode != 404){
        Log::error('Exception', array(
            'errorCode' => $errorCode,
            'requestUrl' => $requestUrl,
            'userAgent' => $userAgent,
            'context' => $exception,
        ));     
    }

    return Response::view('error-page-path.error-404', array(), 404);
    // Here "error-404" is a blade view file in "error-page-path" directory
});