Laravel不断记录“未找到控制器方法”

时间:2014-05-15 14:12:13

标签: php logging laravel

我正在构建一个laravel应用程序,一切似乎都运行良好,除了我不断将这些错误出现在日志文件中的事实。我的意思是他们每隔几分钟出现一次,有时更频繁,有时更少 - 它更难以在日志文件中找到真正的问题。除了这些问题,它们并没有真正导致任何问题 - 我有一个App :: missing方法来照顾真实用户。

您是否知道在哪里寻找解决方案?

[2014-05-15 19:58:20] local.ERROR: exception 'Symfony\Component\HttpKernel\Exception\NotFoundHttpException' with message 'Controller method not found.' in /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:254
Stack trace:
#0 [internal function]: Illuminate\Routing\Controller->missingMethod(Array)
#1 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/Controller.php(231): call_user_func_array(Array, Array)
#2 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(93): Illuminate\Routing\Controller->callAction('missingMethod', Array)
#3 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php(62): Illuminate\Routing\ControllerDispatcher->call(Object(HomeController), Object(Illuminate\Routing\Route), 'missingMethod')
#4 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/Router.php(934): Illuminate\Routing\ControllerDispatcher->dispatch(Object(Illuminate\Routing\Route), Object(Illuminate\Http\Request), 'HomeController', 'missingMethod')
#5 [internal function]: Illuminate\Routing\Router->Illuminate\Routing\{closure}(Array)
#6 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/Route.php(105): call_user_func_array(Object(Closure), Array)
#7 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/Router.php(1000): Illuminate\Routing\Route->run(Object(Illuminate\Http\Request))
#8 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Routing/Router.php(968): Illuminate\Routing\Router->dispatchToRoute(Object(Illuminate\Http\Request))
#9 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(738): Illuminate\Routing\Router->dispatch(Object(Illuminate\Http\Request))
#10 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(708): Illuminate\Foundation\Application->dispatch(Object(Illuminate\Http\Request))
#11 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php(38): Illuminate\Foundation\Application->handle(Object(Illuminate\Http\Request), 1, true)
#12 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Session/Middleware.php(72): Illuminate\Http\FrameGuard->handle(Object(Illuminate\Http\Request), 1, true)
#13 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php(47): Illuminate\Session\Middleware->handle(Object(Illuminate\Http\Request), 1, true)
#14 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php(51): Illuminate\Cookie\Queue->handle(Object(Illuminate\Http\Request), 1, true)
#15 /Applications/MAMP/htdocs/gran.pw/vendor/stack/builder/src/Stack/StackedHttpKernel.php(23): Illuminate\Cookie\Guard->handle(Object(Illuminate\Http\Request), 1, true)
#16 /Applications/MAMP/htdocs/gran.pw/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(606): Stack\StackedHttpKernel->handle(Object(Illuminate\Http\Request))
#17 /Applications/MAMP/htdocs/gran.pw/public/index.php(49): Illuminate\Foundation\Application->run()
#18 {main} [] []

2 个答案:

答案 0 :(得分:0)

看起来你的HomeController没有扩展Laravel的控制器:

class HomeController extends Controller {

}

因为你的方法missingMethod缺少,而且这个方法在Laravel Controller基类中。

答案 1 :(得分:0)

对于不存在的网址,它是404。

即。 http://example.com/this-url-does-not-exist

要查看实际导致404的URL,请将其添加到过滤器文件

App::missing(function($exception)
{
    Log::error('Missing URL was: ' . Request::fullUrl());
});

它将记录日志中发生任何异常的URL。

这很可能是由于搜索引擎机器人试图搜索旧链接,或者可能是您应用程序中的某些损坏的链接。

I did mention this to Taylor as a possible bug in Laravel 4.1 - http异常不会记录丢失的网址 - 但当时已关闭。我可能会重新打开它,因为我确定它是一个错误(因为旧的404确实记录了网址)。