Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

agilasadi's avatar

getActionMethod() in __construct breaks `php artisan route:list`

So recently I used the getActionMethod() function on my controller __construct(), it seems to work properly, but when I run php artisan route:list it throws Call to a member function getActionMethod() on null.

Here is my usage:


$this->method = request()->route()->getActionMethod()

0 likes
1 reply
jlrdw's avatar

Have you tried passing Route $route in the parenthesis.

But not sure, but I believe this works from a method, but you can try it from constructor.

The API doesn't really cover this in much detail.

1 like

Please or to participate in this conversation.