本文介绍了Laravel 5:[在非对象上调用成员函数getAction()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的控制器中,我有
Route::getCurrentRoute()->getAction()['as']
一切都在浏览器中运行良好,但是只要我键入
Everything works well in the browser but as soon as I type
php artisan route:list
在终端机中我有这个异常
in the terminal I have this exception
[Symfony\Component\Debug\Exception\FatalErrorException]
Call to a member function getAction() on a non-object
如果我对此行发表评论,一切都会很好.
If I comment this line everything works well.
推荐答案
似乎很明显吗?
在浏览器中获取当前路线将返回当前访问的路线.在终端中,您没有这样的请求.当询问访问哪条路线时,Laravel将返回null.您必须在调用getAction之前检查返回值.
Get current route in a browser will return the currently visited route. In the terminal you do not have such a request. Laravel will return null when asking what route is visited. You would have to check for the return value before calling getAction.
这篇关于Laravel 5:[在非对象上调用成员函数getAction()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!