Php 使用route:list时无法识别Laravel getPath()

Php 使用route:list时无法识别Laravel getPath(),php,laravel,laravel-4,laravel-5,laravel-artisan,Php,Laravel,Laravel 4,Laravel 5,Laravel Artisan,我正在使用Laravel5,并注意到每当我通过cmd执行php artisan route:list命令时,都会发生一些奇怪的事情 这给了我一个错误: [Symfony\Component\Debug\Exception\FatalErrorException] 对非对象调用成员函数getPath() 它所指的代码如下: Route::getCurrentRoute()->getPath() 但是当我转储代码时,不会抛出任何错误,并且它正确地显示了当前路由 运行php artisan服务时也没有

我正在使用Laravel5,并注意到每当我通过cmd执行
php artisan route:list
命令时,都会发生一些奇怪的事情

这给了我一个错误:
[Symfony\Component\Debug\Exception\FatalErrorException]
对非对象调用成员函数getPath()

它所指的代码如下:
Route::getCurrentRoute()->getPath()

但是当我转储代码时,不会抛出任何错误,并且它正确地显示了当前路由

运行
php artisan服务时也没有问题。使用
php-artisan-route:list
命令时发生错误。路由::getCurrentRoute()->getUri()也是如此。

有人知道这里发生了什么吗?
非常感谢

发生此错误是因为当您在控制台中时,
Route::getCurrentRoute()
返回一个
null
值。如果您在浏览器中,它将返回当前路线。一种解决方案是在检索某些属性之前检查当前路由是否为null:

$currentRoute = Route::getCurrentRoute();

if ($currentRoute) 
{
    $path = $currentRoute->>getPath();
}

哪个文件投掷动作?你需要给它更多的信息。